Skip to content
This repository was archived by the owner on May 13, 2019. It is now read-only.
Closed
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
40 changes: 40 additions & 0 deletions coverage/coverage.sh
Original file line number Diff line number Diff line change
@@ -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
8 changes: 4 additions & 4 deletions coverage/generate-index-html.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@
</div>
''')
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('''
<div class="table-row">
<div>{0}</div>
<div class="sha"><a href="https://github.com/nodejs/node/commit/{1}">{1}</a></div>
<div><a href="coverage-{1}/index.html">{2:05.2f}&nbsp;%</a></div>
<div><a href="coverage-{1}/cxxcoverage.html">{3:05.2f}&nbsp;%</a></div>
</div>'''.format(date, sha, float(jscov), float(cxxcov)))
<div><a href="coverage-{1}/index.html">?&nbsp;%</a></div>
<div><a href="coverage-{1}/cxxcoverage.html">?&nbsp;%</a></div>
</div>'''.format(date, sha))
out.write('''
</div>
</div>
Expand Down
37 changes: 37 additions & 0 deletions coverage/pre-coverage.sh
Original file line number Diff line number Diff line change
@@ -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 [email protected]
"./node" "./deps/npm" install [email protected]

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