diff --git a/coverage/coverage.sh b/coverage/coverage.sh new file mode 100755 index 0000000..a618fe5 --- /dev/null +++ b/coverage/coverage.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +set -e + +COVERAGE_TOOLS_DIR=${COVERAGE_TOOLS_DIR:-"$(pwd)/$(dirname $0)"} +WORKSPACE=${WORKSPACE:-"$(pwd)"} +HOME=${HOME:-"$(pwd)"} + +export PATH="$(pwd):$PATH" +echo "Gathering coverage..." >&2 + +mkdir -p coverage .cov_tmp +"$WORKSPACE/node_modules/.bin/istanbul-merge" --out .cov_tmp/libcov.json \ + 'out/Release/.coverage/coverage-*.json' +(cd lib && "$WORKSPACE/node_modules/.bin/nyc" report \ + --temp-directory "$(pwd)/../.cov_tmp" -r html --report-dir "../coverage") +# (cd out && "$WORKSPACE/gcovr/scripts/gcovr" --gcov-exclude='.*deps' --gcov-exclude='.*usr' -v \ +# -r Release/obj.target/node --html --html-detail \ +# -o ../coverage/cxxcoverage.html) + +mkdir -p "$HOME/coverage-out" +OUTDIR="$HOME/coverage-out/out" +COMMIT_ID=$(git rev-parse --short=16 HEAD) + +mkdir -p "$OUTDIR" +cp -rv coverage "$OUTDIR/coverage-$COMMIT_ID" + +# JSCOVERAGE=$(grep -B1 Lines coverage/index.html | \ +# head -n1 | grep -o '[0-9\.]*') +# CXXCOVERAGE=$(grep -A3 Lines coverage/cxxcoverage.html | \ +# grep style | grep -o '[0-9]\{1,3\}\.[0-9]\{1,2\}') + +# echo "JS Coverage: $JSCOVERAGE %" +# echo "C++ Coverage: $CXXCOVERAGE %" + +NOW=$(date -u +"%Y-%m-%dT%H:%M:%SZ") + +echo "$NOW,$COMMIT_ID" >> "$OUTDIR/index.csv" +cd $OUTDIR/.. +$COVERAGE_TOOLS_DIR/generate-index-html.py diff --git a/coverage/generate-index-html.py b/coverage/generate-index-html.py index 5388115..0f2b7fc 100755 --- a/coverage/generate-index-html.py +++ b/coverage/generate-index-html.py @@ -69,15 +69,15 @@ ''') for line in reversed(index_csv): - jscov, cxxcov, date, sha = line.split(',') + date, sha = line.split(',') date = datetime.datetime.strptime(date, '%Y-%m-%dT%H:%M:%S%fZ').strftime("%d/%m/%Y %H:%M") out.write('''
{0}
{1}
-
{2:05.2f} %
-
{3:05.2f} %
-
'''.format(date, sha, float(jscov), float(cxxcov))) +
? %
+
? %
+ '''.format(date, sha)) out.write(''' diff --git a/coverage/pre-coverage.sh b/coverage/pre-coverage.sh new file mode 100755 index 0000000..349fda8 --- /dev/null +++ b/coverage/pre-coverage.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +set -e + +COVERAGE_TOOLS_DIR=${COVERAGE_TOOLS_DIR:-"$(dirname $0)"} + +# patch things up +patch -p1 < "$COVERAGE_TOOLS_DIR/patches.diff" +export PATH="$(pwd):$PATH" + +# if we don't have our npm dependencies available, build node and fetch them +# with npm +if [ ! -x "./node_modules/.bin/nyc" ] || \ + [ ! -x "./node_modules/.bin/istanbul-merge" ]; then + echo "Building, without lib/ coverage..." >&2 + ./configure + make -j $(getconf _NPROCESSORS_ONLN) node + ./node -v + + + # get nyc + istanbul-merge + "./node" "./deps/npm" install istanbul-merge@1.1.0 + "./node" "./deps/npm" install nyc@8.0.0-candidate + + test -x "./node_modules/.bin/nyc" + test -x "./node_modules/.bin/istanbul-merge" +fi + + +echo "Instrumenting code in lib/..." +"./node_modules/.bin/nyc" instrument lib/ lib_/ +sed -e s~"'"lib/~"'"lib_/~g -i~ node.gyp + +echo "Removing old coverage files" +rm -rf coverage +rm -rf out/Release/.coverage +rm -f out/Release/obj.target/node/src/*.gcda