Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated coverage docs #210

Merged
merged 1 commit into from
Jun 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions build/coverage-report
Original file line number Diff line number Diff line change
@@ -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)
14 changes: 12 additions & 2 deletions docs/dev/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```