From ba907ff750ea18df743252b09f2c29d35ebe285d Mon Sep 17 00:00:00 2001 From: bcoe Date: Thu, 22 Oct 2020 19:56:28 -0700 Subject: test: refactor coverage logic Cleanup logic in Makefile for coverage. Update BUILDING.md accordingly. PR-URL: https://github.com/nodejs/node/pull/35767 Reviewed-By: Rich Trott Reviewed-By: Joyee Cheung --- Makefile | 35 +++++++++-------------------------- 1 file changed, 9 insertions(+), 26 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index b3a0a52e0d..08386412bf 100644 --- a/Makefile +++ b/Makefile @@ -197,20 +197,11 @@ check: test # Remove files generated by running coverage, put the non-instrumented lib back # in place coverage-clean: - if [ -d lib_ ]; then $(RM) -r lib; mv lib_ lib; fi $(RM) -r node_modules $(RM) -r gcovr build - $(RM) -r out/$(BUILDTYPE)/.coverage - $(RM) out/$(BUILDTYPE)/obj.target/node/gen/*.gcda - $(RM) out/$(BUILDTYPE)/obj.target/node/src/*.gcda - $(RM) out/$(BUILDTYPE)/obj.target/node/src/tracing/*.gcda - $(RM) out/$(BUILDTYPE)/obj.target/node/gen/*.gcno - $(RM) out/$(BUILDTYPE)/obj.target/node/src/*.gcno - $(RM) out/$(BUILDTYPE)/obj.target/node/src/tracing/*.gcno - $(RM) out/$(BUILDTYPE)/obj.target/cctest/src/*.gcno - $(RM) out/$(BUILDTYPE)/obj.target/cctest/test/cctest/*.gcno - $(RM) out/$(BUILDTYPE)/obj.target/embedtest/src/*.gcno - $(RM) out/$(BUILDTYPE)/obj.target/embedtest/test/embedding/*.gcno + $(RM) -r coverage/tmp + $(FIND) out/$(BUILDTYPE)/obj.target \( -name "*.gcda" -o -name "*.gcno" \) \ + -type f -exec $(RM) {} \; .PHONY: coverage # Build and test with code coverage reporting. Leave the lib directory @@ -245,8 +236,8 @@ coverage-test: coverage-build $(RM) out/$(BUILDTYPE)/obj.target/node/src/*/*.gcda $(RM) out/$(BUILDTYPE)/obj.target/node_lib/src/*.gcda $(RM) out/$(BUILDTYPE)/obj.target/node_lib/src/*/*.gcda - -NODE_V8_COVERAGE=out/$(BUILDTYPE)/.coverage \ - TEST_CI_ARGS="$(TEST_CI_ARGS) --type=coverage" $(MAKE) $(COVTESTS) + -NODE_V8_COVERAGE=coverage/tmp \ + TEST_CI_ARGS="$(TEST_CI_ARGS) --type=coverage" $(MAKE) $(COVTESTS) $(MAKE) coverage-report-js -(cd out && "../gcovr/scripts/gcovr" \ --gcov-exclude='.*\b(deps|usr|out|cctest|embedding)\b' -v \ @@ -259,17 +250,10 @@ 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="benchmark/" --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 $(COV_REPORT_OPTIONS) + -$(MAKE) coverage-build-js + $(NODE) ./node_modules/.bin/c8 report .PHONY: cctest # Runs the C++ tests using the built `cctest` executable. @@ -305,9 +289,8 @@ tooltest: .PHONY: coverage-run-js coverage-run-js: - $(RM) -r out/$(BUILDTYPE)/.coverage - $(MAKE) coverage-build-js - -NODE_V8_COVERAGE=out/$(BUILDTYPE)/.coverage CI_SKIP_TESTS=$(COV_SKIP_TESTS) \ + $(RM) -r coverage/tmp + -NODE_V8_COVERAGE=coverage/tmp CI_SKIP_TESTS=$(COV_SKIP_TESTS) \ TEST_CI_ARGS="$(TEST_CI_ARGS) --type=coverage" $(MAKE) jstest $(MAKE) coverage-report-js -- cgit v1.2.1