diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2018-12-29 18:44:11 +0800 |
---|---|---|
committer | Joyee Cheung <joyeec9h3@gmail.com> | 2019-01-16 13:49:36 +0800 |
commit | b367ab2a6624b41bd59b751c61cf64ad91a9e2d6 (patch) | |
tree | 60e2e85a2f60bb773a642d6c948855072ff3e3d6 /lib/internal/bootstrap/loaders.js | |
parent | 2b401e33de81428dc5f6dfc60343e65ee5167886 (diff) | |
download | android-node-v8-b367ab2a6624b41bd59b751c61cf64ad91a9e2d6.tar.gz android-node-v8-b367ab2a6624b41bd59b751c61cf64ad91a9e2d6.tar.bz2 android-node-v8-b367ab2a6624b41bd59b751c61cf64ad91a9e2d6.zip |
process: refactor coverage setup during bootstrap
- Renamed `internal/process/write-coverage.js` to
`internal/coverage-gen/with_instrumentation.js`,
`internal/process/coverage.js` to
`internal/coverage-gen/with_profiler.js` to distinguish
the two better and added comments.
- Separate the coverage directory setup and the connection
setup, moves the directory setup into `node.js` and
closer to the exit hooks because that's where it's used.
- Moves the `process.reallyExit` overwrite and
`process.on('exit')` hooks setup into bootstrap/node.js
for clarity, and move them to a later stage of
bootstrap since they do not have to happen that early.
PR-URL: https://github.com/nodejs/node/pull/25398
Reviewed-By: Ben Coe <bencoe@gmail.com>
Diffstat (limited to 'lib/internal/bootstrap/loaders.js')
-rw-r--r-- | lib/internal/bootstrap/loaders.js | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/internal/bootstrap/loaders.js b/lib/internal/bootstrap/loaders.js index 300a362abb..4554526298 100644 --- a/lib/internal/bootstrap/loaders.js +++ b/lib/internal/bootstrap/loaders.js @@ -329,7 +329,14 @@ NativeModule.prototype.compile = function() { // Coverage must be turned on early, so that we can collect // it for Node.js' own internal libraries. if (process.env.NODE_V8_COVERAGE) { - NativeModule.require('internal/process/coverage').setup(); + if (internalBinding('config').hasInspector) { + const coverage = + NativeModule.require('internal/coverage-gen/with_profiler'); + // Inform the profiler to start collecting coverage + coverage.startCoverageCollection(); + } else { + process._rawDebug('NODE_V8_COVERAGE cannot be used without inspector'); + } } function internalBindingWhitelistHas(name) { |