test: allow coverage threshold to be enforced

If COV_ENFORCE_THRESHOLD is set, tests run in coverage mode will
exit with an error, if line coverage is below the percentage
threshold.

PR-URL: https://github.com/nodejs/node/pull/25675
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
This commit is contained in:
Benjamin Coe 2019-01-30 15:51:21 -08:00 committed by Benjamin
parent 0ff0af534e
commit a861adde3b
No known key found for this signature in database
GPG Key ID: 60AB1C1D478E1286

View File

@ -215,7 +215,7 @@ coverage-build: all
coverage-build-js:
mkdir -p node_modules
if [ ! -d node_modules/c8 ]; then \
$(NODE) ./deps/npm install c8@next --no-save --no-package-lock;\
$(NODE) ./deps/npm install c8 --no-save --no-package-lock;\
fi
.PHONY: coverage-test
@ -240,12 +240,17 @@ coverage-test: coverage-build
@grep -A3 Lines coverage/cxxcoverage.html | grep style \
| sed 's/<[^>]*>//g'| sed 's/ //g'
COV_REPORT_OPTIONS = --reporter=html \
--temp-directory=out/$(BUILDTYPE)/.coverage --omit-relative=false \
--resolve=./lib --exclude="deps/" --exclude="test/" --exclude="tools/" \
--wrapper-length=0
ifdef COV_ENFORCE_THRESHOLD
COV_REPORT_OPTIONS += --check-coverage --lines=$(COV_ENFORCE_THRESHOLD)
endif
.PHONY: coverage-report-js
coverage-report-js:
$(NODE) ./node_modules/.bin/c8 report --reporter=html \
--temp-directory=out/$(BUILDTYPE)/.coverage --omit-relative=false \
--resolve=./lib --exclude="deps/" --exclude="test/" --exclude="tools/" \
--wrapper-length=0
$(NODE) ./node_modules/.bin/c8 report $(COV_REPORT_OPTIONS)
.PHONY: cctest
# Runs the C++ tests using the built `cctest` executable.