Skip to content

Commit 704a440

Browse files
bcoeaddaleax
authored andcommitted
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: #25675 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
1 parent 673e434 commit 704a440

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

Makefile

+10-5
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ coverage-build: all
215215
coverage-build-js:
216216
mkdir -p node_modules
217217
if [ ! -d node_modules/c8 ]; then \
218-
$(NODE) ./deps/npm install c8@next --no-save --no-package-lock;\
218+
$(NODE) ./deps/npm install c8 --no-save --no-package-lock;\
219219
fi
220220

221221
.PHONY: coverage-test
@@ -240,12 +240,17 @@ coverage-test: coverage-build
240240
@grep -A3 Lines coverage/cxxcoverage.html | grep style \
241241
| sed 's/<[^>]*>//g'| sed 's/ //g'
242242

243+
COV_REPORT_OPTIONS = --reporter=html \
244+
--temp-directory=out/$(BUILDTYPE)/.coverage --omit-relative=false \
245+
--resolve=./lib --exclude="deps/" --exclude="test/" --exclude="tools/" \
246+
--wrapper-length=0
247+
ifdef COV_ENFORCE_THRESHOLD
248+
COV_REPORT_OPTIONS += --check-coverage --lines=$(COV_ENFORCE_THRESHOLD)
249+
endif
250+
243251
.PHONY: coverage-report-js
244252
coverage-report-js:
245-
$(NODE) ./node_modules/.bin/c8 report --reporter=html \
246-
--temp-directory=out/$(BUILDTYPE)/.coverage --omit-relative=false \
247-
--resolve=./lib --exclude="deps/" --exclude="test/" --exclude="tools/" \
248-
--wrapper-length=0
253+
$(NODE) ./node_modules/.bin/c8 report $(COV_REPORT_OPTIONS)
249254

250255
.PHONY: cctest
251256
# Runs the C++ tests using the built `cctest` executable.

0 commit comments

Comments
 (0)