| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -389,28 +389,32 @@ $ make coverage | |||
| 389 | 389 | ``` | |
| 390 | 390 | ||
| 391 | 391 | A detailed coverage report will be written to `coverage/index.html` for | |
| 392 | - JavaScript coverage and to `coverage/cxxcoverage.html` for C++ coverage | ||
| 393 | - (if you only want to run the JavaScript tests then you do not need to run | ||
| 394 | - the first command `./configure --coverage`). | ||
| 392 | + JavaScript coverage and to `coverage/cxxcoverage.html` for C++ coverage. | ||
| 395 | 393 | ||
| 396 | - _Generating a test coverage report can take several minutes._ | ||
| 397 | - | ||
| 398 | - To collect coverage for a subset of tests you can set the `CI_JS_SUITES` and | ||
| 399 | - `CI_NATIVE_SUITES` variables (to run specific suites, e.g., `child-process`, in | ||
| 400 | - isolation, unset the opposing `_SUITES` variable): | ||
| 394 | + If you only want to run the JavaScript tests then you do not need to run | ||
| 395 | + the first command (`./configure --coverage`). Run `make coverage-run-js`, | ||
| 396 | + to execute JavaScript tests independently of the C++ test suite: | ||
| 401 | 397 | ||
| 402 | 398 | ```text | |
| 403 | - $ CI_JS_SUITES=child-process CI_NATIVE_SUITES= make coverage | ||
| 399 | + $ make coverage-run-js | ||
| 404 | 400 | ``` | |
| 405 | 401 | ||
| 406 | - The above command executes tests for the `child-process` subsystem and | ||
| 407 | - outputs the resulting coverage report. | ||
| 402 | + If you are updating tests and want to collect coverrage for a single test file | ||
| 403 | + (e.g. `test/parallel/test-stream2-transform.js`): | ||
| 404 | + | ||
| 405 | + ```text | ||
| 406 | + $ make coverage-clean | ||
| 407 | + $ NODE_V8_COVERAGE=coverage/tmp python tools/test.py test/parallel/test-stream2-transform.js | ||
| 408 | + $ make coverage-report-js | ||
| 409 | + ``` | ||
| 408 | 410 | ||
| 409 | - Alternatively, you can run `make coverage-run-js`, to execute JavaScript tests | ||
| 410 | - independently of the C++ test suite: | ||
| 411 | + You can collect coverage for the entire suite of tests for a given subsystem | ||
| 412 | + by providing the name of a subsystem: | ||
| 411 | 413 | ||
| 412 | 414 | ```text | |
| 413 | - $ CI_JS_SUITES=fs CI_NATIVE_SUITES= make coverage-run-js | ||
| 415 | + $ make coverage-clean | ||
| 416 | + $ NODE_V8_COVERAGE=coverage/tmp python tools/test.py -J --mode=release child-process | ||
| 417 | + $ make coverage-report-js | ||
| 414 | 418 | ``` | |
| 415 | 419 | ||
| 416 | 420 | The `make coverage` command downloads some tools to the project root directory. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -197,20 +197,11 @@ check: test | |||
| 197 | 197 | # Remove files generated by running coverage, put the non-instrumented lib back | |
| 198 | 198 | # in place | |
| 199 | 199 | coverage-clean: | |
| 200 | - if [ -d lib_ ]; then $(RM) -r lib; mv lib_ lib; fi | ||
| 201 | 200 | $(RM) -r node_modules | |
| 202 | 201 | $(RM) -r gcovr build | |
| 203 | - $(RM) -r out/$(BUILDTYPE)/.coverage | ||
| 204 | - $(RM) out/$(BUILDTYPE)/obj.target/node/gen/*.gcda | ||
| 205 | - $(RM) out/$(BUILDTYPE)/obj.target/node/src/*.gcda | ||
| 206 | - $(RM) out/$(BUILDTYPE)/obj.target/node/src/tracing/*.gcda | ||
| 207 | - $(RM) out/$(BUILDTYPE)/obj.target/node/gen/*.gcno | ||
| 208 | - $(RM) out/$(BUILDTYPE)/obj.target/node/src/*.gcno | ||
| 209 | - $(RM) out/$(BUILDTYPE)/obj.target/node/src/tracing/*.gcno | ||
| 210 | - $(RM) out/$(BUILDTYPE)/obj.target/cctest/src/*.gcno | ||
| 211 | - $(RM) out/$(BUILDTYPE)/obj.target/cctest/test/cctest/*.gcno | ||
| 212 | - $(RM) out/$(BUILDTYPE)/obj.target/embedtest/src/*.gcno | ||
| 213 | - $(RM) out/$(BUILDTYPE)/obj.target/embedtest/test/embedding/*.gcno | ||
| 202 | + $(RM) -r coverage/tmp | ||
| 203 | + $(FIND) out/$(BUILDTYPE)/obj.target \( -name "*.gcda" -o -name "*.gcno" \) \ | ||
| 204 | + -type f -exec $(RM) {} \; | ||
| 214 | 205 | ||
| 215 | 206 | .PHONY: coverage | |
| 216 | 207 | # Build and test with code coverage reporting. Leave the lib directory | |
@@ -245,8 +236,8 @@ coverage-test: coverage-build | |||
| 245 | 236 | $(RM) out/$(BUILDTYPE)/obj.target/node/src/*/*.gcda | |
| 246 | 237 | $(RM) out/$(BUILDTYPE)/obj.target/node_lib/src/*.gcda | |
| 247 | 238 | $(RM) out/$(BUILDTYPE)/obj.target/node_lib/src/*/*.gcda | |
| 248 | - -NODE_V8_COVERAGE=out/$(BUILDTYPE)/.coverage \ | ||
| 249 | - TEST_CI_ARGS="$(TEST_CI_ARGS) --type=coverage" $(MAKE) $(COVTESTS) | ||
| 239 | + -NODE_V8_COVERAGE=coverage/tmp \ | ||
| 240 | + TEST_CI_ARGS="$(TEST_CI_ARGS) --type=coverage" $(MAKE) $(COVTESTS) | ||
| 250 | 241 | $(MAKE) coverage-report-js | |
| 251 | 242 | -(cd out && "../gcovr/scripts/gcovr" \ | |
| 252 | 243 | --gcov-exclude='.*\b(deps|usr|out|cctest|embedding)\b' -v \ | |
@@ -259,17 +250,10 @@ coverage-test: coverage-build | |||
| 259 | 250 | @grep -A3 Lines coverage/cxxcoverage.html | grep style \ | |
| 260 | 251 | | sed 's/<[^>]*>//g'| sed 's/ //g' | |
| 261 | 252 | ||
| 262 | - COV_REPORT_OPTIONS = --reporter=html \ | ||
| 263 | - --temp-directory=out/$(BUILDTYPE)/.coverage --omit-relative=false \ | ||
| 264 | - --resolve=./lib --exclude="benchmark/" --exclude="deps/" --exclude="test/" --exclude="tools/" \ | ||
| 265 | - --wrapper-length=0 | ||
| 266 | - ifdef COV_ENFORCE_THRESHOLD | ||
| 267 | - COV_REPORT_OPTIONS += --check-coverage --lines=$(COV_ENFORCE_THRESHOLD) | ||
| 268 | - endif | ||
| 269 | - | ||
| 270 | 253 | .PHONY: coverage-report-js | |
| 271 | 254 | coverage-report-js: | |
| 272 | - $(NODE) ./node_modules/.bin/c8 report $(COV_REPORT_OPTIONS) | ||
| 255 | + -$(MAKE) coverage-build-js | ||
| 256 | + $(NODE) ./node_modules/.bin/c8 report | ||
| 273 | 257 | ||
| 274 | 258 | .PHONY: cctest | |
| 275 | 259 | # Runs the C++ tests using the built `cctest` executable. | |
@@ -305,9 +289,8 @@ tooltest: | |||
| 305 | 289 | ||
| 306 | 290 | .PHONY: coverage-run-js | |
| 307 | 291 | coverage-run-js: | |
| 308 | - $(RM) -r out/$(BUILDTYPE)/.coverage | ||
| 309 | - $(MAKE) coverage-build-js | ||
| 310 | - -NODE_V8_COVERAGE=out/$(BUILDTYPE)/.coverage CI_SKIP_TESTS=$(COV_SKIP_TESTS) \ | ||
| 292 | + $(RM) -r coverage/tmp | ||
| 293 | + -NODE_V8_COVERAGE=coverage/tmp CI_SKIP_TESTS=$(COV_SKIP_TESTS) \ | ||
| 311 | 294 | TEST_CI_ARGS="$(TEST_CI_ARGS) --type=coverage" $(MAKE) jstest | |
| 312 | 295 | $(MAKE) coverage-report-js | |
| 313 | 296 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments