summaryrefslogtreecommitdiff
path: root/lib/internal/bootstrap/pre_execution.js
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2019-03-23 07:39:52 +0800
committerJoyee Cheung <joyeec9h3@gmail.com>2019-04-06 12:01:45 +0800
commit864860e9f3d4eed0b0b81af55197d7e525ea6306 (patch)
treeed0c9cbc1cea99323cd4fa4c5385a11b262be8ee /lib/internal/bootstrap/pre_execution.js
parentbaa54a5ae78ff04a3e8d8ac97c052304a6f6c18c (diff)
downloadandroid-node-v8-864860e9f3d4eed0b0b81af55197d7e525ea6306.tar.gz
android-node-v8-864860e9f3d4eed0b0b81af55197d7e525ea6306.tar.bz2
android-node-v8-864860e9f3d4eed0b0b81af55197d7e525ea6306.zip
src: port coverage serialization to C++
This patch moves the serialization of coverage profiles into C++. With this we no longer need to patch `process.reallyExit` and hook into the exit events, but instead hook into relevant places in C++ which are safe from user manipulation. This also makes the code easier to reuse for other types of profiles. PR-URL: https://github.com/nodejs/node/pull/26874 Reviewed-By: Ben Coe <bencoe@gmail.com>
Diffstat (limited to 'lib/internal/bootstrap/pre_execution.js')
-rw-r--r--lib/internal/bootstrap/pre_execution.js12
1 files changed, 1 insertions, 11 deletions
diff --git a/lib/internal/bootstrap/pre_execution.js b/lib/internal/bootstrap/pre_execution.js
index 297aea9dd7..c1c58a81ff 100644
--- a/lib/internal/bootstrap/pre_execution.js
+++ b/lib/internal/bootstrap/pre_execution.js
@@ -110,20 +110,10 @@ function setupWarningHandler() {
// Setup User-facing NODE_V8_COVERAGE environment variable that writes
// ScriptCoverage to a specified file.
function setupCoverageHooks(dir) {
- const originalReallyExit = process.reallyExit;
const cwd = require('internal/process/execution').tryGetCwd();
const { resolve } = require('path');
const coverageDirectory = resolve(cwd, dir);
- const {
- writeCoverage,
- setCoverageDirectory
- } = require('internal/profiler');
- setCoverageDirectory(coverageDirectory);
- process.on('exit', writeCoverage);
- process.reallyExit = (code) => {
- writeCoverage();
- originalReallyExit(code);
- };
+ internalBinding('profiler').setCoverageDirectory(coverageDirectory);
return coverageDirectory;
}