| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 593714e commit 7490fc8
7 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -290,9 +290,15 @@ $ CI_JS_SUITES=child-process CI_NATIVE_SUITES= make coverage | |||
| 290 | 290 | The above command executes tests for the `child-process` subsystem and | |
| 291 | 291 | outputs the resulting coverage report. | |
| 292 | 292 | ||
| 293 | - The `make coverage` command downloads some tools to the project root directory | ||
| 294 | - and overwrites the `lib/` directory. To clean up after generating the coverage | ||
| 295 | - reports: | ||
| 293 | + Alternatively, for the JavaScript test suite, you can use the `CI_JS_SUITES` | ||
| 294 | + variable to run tests in isolation, outputting reports: | ||
| 295 | + | ||
| 296 | + ```text | ||
| 297 | + $ CI_JS_SUITES=fs CI_NATIVE_SUITES= make coverage-run-js | ||
| 298 | + ``` | ||
| 299 | + | ||
| 300 | + The `make coverage` command downloads some tools to the project root directory. | ||
| 301 | + To clean up after generating the coverage reports: | ||
| 296 | 302 | ||
| 297 | 303 | ```console | |
| 298 | 304 | $ make coverage-clean | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,6 +11,7 @@ STAGINGSERVER ?= node-www | |||
| 11 | 11 | LOGLEVEL ?= silent | |
| 12 | 12 | OSTYPE := $(shell uname -s | tr '[A-Z]' '[a-z]') | |
| 13 | 13 | COVTESTS ?= test-cov | |
| 14 | + COV_SKIP_TESTS ?= core_line_numbers.js,testFinalizer.js,test_function/test.js | ||
| 14 | 15 | GTEST_FILTER ?= "*" | |
| 15 | 16 | GNUMAKEFLAGS += --no-print-directory | |
| 16 | 17 | GCOV ?= gcov | |
@@ -181,7 +182,6 @@ coverage-clean: | |||
| 181 | 182 | $(RM) -r node_modules | |
| 182 | 183 | $(RM) -r gcovr build | |
| 183 | 184 | $(RM) -r out/$(BUILDTYPE)/.coverage | |
| 184 | - $(RM) -r .cov_tmp | ||
| 185 | 185 | $(RM) out/$(BUILDTYPE)/obj.target/node/gen/*.gcda | |
| 186 | 186 | $(RM) out/$(BUILDTYPE)/obj.target/node/src/*.gcda | |
| 187 | 187 | $(RM) out/$(BUILDTYPE)/obj.target/node/src/tracing/*.gcda | |
@@ -201,55 +201,51 @@ coverage: coverage-test ## Run the tests and generate a coverage report. | |||
| 201 | 201 | ||
| 202 | 202 | .PHONY: coverage-build | |
| 203 | 203 | coverage-build: all | |
| 204 | - mkdir -p node_modules | ||
| 205 | - if [ ! -d node_modules/nyc ]; then \ | ||
| 206 | - $(NODE) ./deps/npm install nyc@13 --no-save --no-package-lock; fi | ||
| 204 | + -$(MAKE) coverage-build-js | ||
| 207 | 205 | if [ ! -d gcovr ]; then git clone -b 3.4 --depth=1 \ | |
| 208 | 206 | --single-branch https://github.com/gcovr/gcovr.git; fi | |
| 209 | 207 | if [ ! -d build ]; then git clone --depth=1 \ | |
| 210 | 208 | --single-branch https://github.com/nodejs/build.git; fi | |
| 211 | 209 | if [ ! -f gcovr/scripts/gcovr.orig ]; then \ | |
| 212 | 210 | (cd gcovr && patch -N -p1 < \ | |
| 213 | 211 | "$(CURDIR)/build/jenkins/scripts/coverage/gcovr-patches-3.4.diff"); fi | |
| 214 | - if [ -d lib_ ]; then $(RM) -r lib; mv lib_ lib; fi | ||
| 215 | - mv lib lib_ | ||
| 216 | - NODE_DEBUG=nyc $(NODE) ./node_modules/.bin/nyc instrument --extension .js \ | ||
| 217 | - --extension .mjs --exit-on-error lib_/ lib/ | ||
| 218 | 212 | $(MAKE) | |
| 219 | 213 | ||
| 214 | + .PHONY: coverage-build-js | ||
| 215 | + coverage-build-js: | ||
| 216 | + mkdir -p node_modules | ||
| 217 | + if [ ! -d node_modules/c8 ]; then \ | ||
| 218 | + $(NODE) ./deps/npm install c8@next --no-save --no-package-lock;\ | ||
| 219 | + fi | ||
| 220 | + | ||
| 220 | 221 | .PHONY: coverage-test | |
| 221 | 222 | coverage-test: coverage-build | |
| 222 | - $(RM) -r out/$(BUILDTYPE)/.coverage | ||
| 223 | - $(RM) -r .cov_tmp | ||
| 224 | 223 | $(RM) out/$(BUILDTYPE)/obj.target/node/gen/*.gcda | |
| 225 | 224 | $(RM) out/$(BUILDTYPE)/obj.target/node/src/*.gcda | |
| 226 | 225 | $(RM) out/$(BUILDTYPE)/obj.target/node/src/tracing/*.gcda | |
| 227 | 226 | $(RM) out/$(BUILDTYPE)/obj.target/node_lib/gen/*.gcda | |
| 228 | 227 | $(RM) out/$(BUILDTYPE)/obj.target/node_lib/src/*.gcda | |
| 229 | 228 | $(RM) out/$(BUILDTYPE)/obj.target/node_lib/src/tracing/*.gcda | |
| 230 | - -$(MAKE) $(COVTESTS) | ||
| 231 | - mv lib lib__ | ||
| 232 | - mv lib_ lib | ||
| 233 | - mkdir -p coverage .cov_tmp | ||
| 234 | - $(NODE) ./node_modules/.bin/nyc merge 'out/Release/.coverage' \ | ||
| 235 | - .cov_tmp/libcov.json | ||
| 236 | - (cd lib && .$(NODE) ../node_modules/.bin/nyc report \ | ||
| 237 | - --temp-dir "$(CURDIR)/.cov_tmp" \ | ||
| 238 | - --report-dir "$(CURDIR)/coverage" \ | ||
| 239 | - --reporter html) | ||
| 229 | + -NODE_V8_COVERAGE=out/$(BUILDTYPE)/.coverage $(MAKE) $(COVTESTS) | ||
| 230 | + $(MAKE) coverage-report-js | ||
| 240 | 231 | -(cd out && "../gcovr/scripts/gcovr" --gcov-exclude='.*deps' \ | |
| 241 | 232 | --gcov-exclude='.*usr' -v -r Release/obj.target \ | |
| 242 | 233 | --html --html-detail -o ../coverage/cxxcoverage.html \ | |
| 243 | 234 | --gcov-executable="$(GCOV)") | |
| 244 | - mv lib lib_ | ||
| 245 | - mv lib__ lib | ||
| 246 | 235 | @echo -n "Javascript coverage %: " | |
| 247 | 236 | @grep -B1 Lines coverage/index.html | head -n1 \ | |
| 248 | 237 | | sed 's/<[^>]*>//g'| sed 's/ //g' | |
| 249 | 238 | @echo -n "C++ coverage %: " | |
| 250 | 239 | @grep -A3 Lines coverage/cxxcoverage.html | grep style \ | |
| 251 | 240 | | sed 's/<[^>]*>//g'| sed 's/ //g' | |
| 252 | 241 | ||
| 242 | + .PHONY: coverage-report-js | ||
| 243 | + coverage-report-js: | ||
| 244 | + $(NODE) ./node_modules/.bin/c8 report --reporter=html \ | ||
| 245 | + --temp-directory=out/$(BUILDTYPE)/.coverage --omit-relative=false \ | ||
| 246 | + --resolve=./lib --exclude="deps/" --exclude="test/" --exclude="tools/" \ | ||
| 247 | + --wrapper-length=0 | ||
| 248 | + | ||
| 253 | 249 | .PHONY: cctest | |
| 254 | 250 | # Runs the C++ tests using the built `cctest` executable. | |
| 255 | 251 | cctest: all | |
@@ -276,6 +272,14 @@ jstest: build-addons build-js-native-api-tests build-node-api-tests ## Runs addo | |||
| 276 | 272 | $(CI_JS_SUITES) \ | |
| 277 | 273 | $(CI_NATIVE_SUITES) | |
| 278 | 274 | ||
| 275 | + .PHONY: coverage-run-js | ||
| 276 | + coverage-run-js: | ||
| 277 | + $(RM) -r out/$(BUILDTYPE)/.coverage | ||
| 278 | + $(MAKE) coverage-build-js | ||
| 279 | + -NODE_V8_COVERAGE=out/$(BUILDTYPE)/.coverage CI_SKIP_TESTS=$(COV_SKIP_TESTS) \ | ||
| 280 | + $(MAKE) jstest | ||
| 281 | + $(MAKE) coverage-report-js | ||
| 282 | + | ||
| 279 | 283 | .PHONY: test | |
| 280 | 284 | # This does not run tests of third-party libraries inside deps. | |
| 281 | 285 | test: all ## Runs default tests, linters, and builds docs. | |
@@ -300,7 +304,7 @@ test-cov: all | |||
| 300 | 304 | $(MAKE) build-js-native-api-tests | |
| 301 | 305 | $(MAKE) build-node-api-tests | |
| 302 | 306 | # $(MAKE) cctest | |
| 303 | - CI_SKIP_TESTS=core_line_numbers.js $(MAKE) jstest | ||
| 307 | + CI_SKIP_TESTS=$(COV_SKIP_TESTS) $(MAKE) jstest | ||
| 304 | 308 | ||
| 305 | 309 | test-parallel: all | |
| 306 | 310 | $(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) parallel | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -301,26 +301,10 @@ function startup() { | |||
| 301 | 301 | } | |
| 302 | 302 | }); | |
| 303 | 303 | ||
| 304 | - // Set up coverage exit hooks. | ||
| 305 | - let originalReallyExit = process.reallyExit; | ||
| 306 | - // Core coverage generation using nyc instrumented lib/ files. | ||
| 307 | - // See `make coverage-build`. This does not affect user land. | ||
| 308 | - // TODO(joyeecheung): this and `with_instrumentation.js` can be | ||
| 309 | - // removed in favor of NODE_V8_COVERAGE once we switch to that | ||
| 310 | - // in https://coverage.nodejs.org/ | ||
| 311 | - if (global.__coverage__) { | ||
| 312 | - const { | ||
| 313 | - writeCoverage | ||
| 314 | - } = NativeModule.require('internal/coverage-gen/with_instrumentation'); | ||
| 315 | - process.on('exit', writeCoverage); | ||
| 316 | - originalReallyExit = process.reallyExit = (code) => { | ||
| 317 | - writeCoverage(); | ||
| 318 | - originalReallyExit(code); | ||
| 319 | - }; | ||
| 320 | - } | ||
| 321 | 304 | // User-facing NODE_V8_COVERAGE environment variable that writes | |
| 322 | 305 | // ScriptCoverage to a specified file. | |
| 323 | 306 | if (process.env.NODE_V8_COVERAGE) { | |
| 307 | + const originalReallyExit = process.reallyExit; | ||
| 324 | 308 | const cwd = NativeModule.require('internal/process/execution').tryGetCwd(); | |
| 325 | 309 | const { resolve } = NativeModule.require('path'); | |
| 326 | 310 | // Resolve the coverage directory to an absolute path, and | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -99,7 +99,6 @@ | |||
| 99 | 99 | 'lib/internal/console/constructor.js', | |
| 100 | 100 | 'lib/internal/console/global.js', | |
| 101 | 101 | 'lib/internal/coverage-gen/with_profiler.js', | |
| 102 | - 'lib/internal/coverage-gen/with_instrumentation.js', | ||
| 103 | 102 | 'lib/internal/crypto/certificate.js', | |
| 104 | 103 | 'lib/internal/crypto/cipher.js', | |
| 105 | 104 | 'lib/internal/crypto/diffiehellman.js', | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -238,9 +238,6 @@ function platformTimeout(ms) { | |||
| 238 | 238 | if (process.features.debug) | |
| 239 | 239 | ms = multipliers.two * ms; | |
| 240 | 240 | ||
| 241 | - if (global.__coverage__) | ||
| 242 | - ms = multipliers.four * ms; | ||
| 243 | - | ||
| 244 | 241 | if (isAIX) | |
| 245 | 242 | return multipliers.two * ms; // default localhost speed is slower on AIX | |
| 246 | 243 | ||
@@ -310,11 +307,7 @@ function leakedGlobals() { | |||
| 310 | 307 | } | |
| 311 | 308 | } | |
| 312 | 309 | ||
| 313 | - if (global.__coverage__) { | ||
| 314 | - return leaked.filter((varname) => !/^(?:cov_|__cov)/.test(varname)); | ||
| 315 | - } else { | ||
| 316 | - return leaked; | ||
| 317 | - } | ||
| 310 | + return leaked; | ||
| 318 | 311 | } | |
| 319 | 312 | ||
| 320 | 313 | process.on('exit', function() { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,7 +9,8 @@ const common = require('../common'); | |||
| 9 | 9 | const assert = require('assert'); | |
| 10 | 10 | ||
| 11 | 11 | const isMainThread = common.isMainThread; | |
| 12 | - const kMaxModuleCount = isMainThread ? 64 : 84; | ||
| 12 | + const kCoverageModuleCount = process.env.NODE_V8_COVERAGE ? 1 : 0; | ||
| 13 | + const kMaxModuleCount = (isMainThread ? 64 : 84) + kCoverageModuleCount; | ||
| 13 | 14 | ||
| 14 | 15 | assert(list.length <= kMaxModuleCount, | |
| 15 | 16 | `Total length: ${list.length}\n` + list.join('\n') | |
| Back | FazBrowse Home | New Git URL |
0 commit comments