From 559e9de3202d8133981a3db82429c81fc6ecbb65 Mon Sep 17 00:00:00 2001 From: "Robert (Bobby) Evans" Date: Thu, 18 Jun 2020 10:38:28 -0500 Subject: [PATCH] Updated coverage docs --- build/coverage-report | 50 +++++++++++++++++++++++++++++++++++++++++++ docs/dev/README.md | 14 ++++++++++-- 2 files changed, 62 insertions(+), 2 deletions(-) create mode 100755 build/coverage-report diff --git a/build/coverage-report b/build/coverage-report new file mode 100755 index 00000000000..a8bf2653cbf --- /dev/null +++ b/build/coverage-report @@ -0,0 +1,50 @@ +#!/bin/bash + +# +# Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +set -e +JVER=${JACOCO_VERSION:-"0.8.5"} +JDEST=${JACOCO_DEST:-"./target/jacococli.jar"} +TMP_CLASS=${TEMP_CLASS_LOC:-"./target/jacoco_classes/"} +HTML_LOC=${HTML_LOCATION:="./target/jacoco-report/"} +DIST_JAR=${RAPIDS_DIST_JAR:-$(ls ./dist/target/rapids-4-spark_2.12-*.jar | grep -v test | xargs readlink -f)} +SOURCE_DIRS=${SOURCE_DIRS:-"./sql-plugin/src/main/scala/:./sql-plugin/src/main/java/:./shuffle-plugin/src/main/scala/"} + +SOURCE_WITH_ARGS="--sourcefiles "$(echo $SOURCE_DIRS | sed -e 's/:/ --sourcefiles /g') + +# Clean up the classes so we can build the report cleanly +rm -rf "$TMP_CLASS" +mkdir -p "$TMP_CLASS" +pushd "$TMP_CLASS" +jar xf "$DIST_JAR" +rm -rf com/nvidia/shaded/ org/openucx/ +popd + +if [ ! -f "$JDEST" ]; then + # get the jacoco jar + mvn dependency:get -DgroupId=org.jacoco -DartifactId=org.jacoco.cli -Dclassifier=nodeps -Dversion="$JVER" -Ddest="$JDEST" +fi + +if [ "$#" != "0" ]; then + ARGS=$@ +else + ARGS=$(find . -name "jacoco.exec" -printf "%p ") +fi +# run the report +java -jar "$JDEST" report --classfiles "$TMP_CLASS" --html "$HTML_LOC" $SOURCE_WITH_ARGS $ARGS + +echo "The report is at file://"$(readlink -f "$HTML_LOC"/index.html) diff --git a/docs/dev/README.md b/docs/dev/README.md index a7d01186d7a..b8ddfc80333 100644 --- a/docs/dev/README.md +++ b/docs/dev/README.md @@ -237,8 +237,18 @@ setting up the build for profiling and adding NVTX ranges. ## Code Coverage -A code coverage report can be generated by running the follow command. +We use [jacoco](https://www.jacoco.org/jacoco/trunk/doc/) for code coverage because it lets +us gather code coverage for both Java and Scala. It also lets us instrument shaded jars, +and use tests that are written in pyspark. We have had to jump through some hoops to make +it work, which is partly why the tests are in the `test` and `integration_test` directories. + +The regular [jacoco maven plugin](https://www.jacoco.org/jacoco/trunk/doc/maven.html), however +is not currently [able to support](https://github.com/jacoco/jacoco/issues/965) this type of +setup. So if you want to generate a coverage report you need to do it manually. Coverage is +collected by default so first run the tests, and then generate the report, this should be run +from the root project directory. It will print out the URL of the report at the end. ```bash -mvn scoverage:report +mvn clean verify +./build/coverage-report ``` \ No newline at end of file