2014-02-05 13:11:21 +00:00
|
|
|
postPhases+=" coverageReportPhase"
|
|
|
|
|
|
|
|
coverageReportPhase() {
|
|
|
|
lcov --directory . --capture --output-file app.info
|
|
|
|
set -o noglob
|
2014-02-05 13:37:43 +00:00
|
|
|
lcov --remove app.info ${lcovFilter:-"/nix/store/*"} > app2.info
|
2014-02-05 13:11:21 +00:00
|
|
|
set +o noglob
|
|
|
|
mv app2.info app.info
|
|
|
|
|
|
|
|
mkdir -p $out/coverage
|
|
|
|
genhtml app.info $lcovExtraTraceFiles -o $out/coverage > log
|
|
|
|
|
2015-07-30 16:29:19 +01:00
|
|
|
# Grab the overall coverage percentage so that Hydra can plot it over time.
|
2014-02-05 13:11:21 +00:00
|
|
|
mkdir -p $out/nix-support
|
2015-07-30 16:29:19 +01:00
|
|
|
lineCoverage="$(sed 's/.*lines\.*: \([0-9\.]\+\)%.*/\1/; t ; d' log)"
|
|
|
|
functionCoverage="$(sed 's/.*functions\.*: \([0-9\.]\+\)%.*/\1/; t ; d' log)"
|
|
|
|
if [ -z "$lineCoverage" -o -z "$functionCoverage" ]; then
|
|
|
|
echo "failed to get coverage statistics"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
echo "lineCoverage $lineCoverage %" >> $out/nix-support/hydra-metrics
|
|
|
|
echo "functionCoverage $functionCoverage %" >> $out/nix-support/hydra-metrics
|
2014-02-05 13:11:21 +00:00
|
|
|
|
|
|
|
echo "report coverage $out/coverage" >> $out/nix-support/hydra-build-products
|
|
|
|
}
|