-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a v8.stopCoverage() API to stop the coverage collection started by NODE_V8_COVERAGE - this would be useful in conjunction with v8.takeCoverage() if the user don't want to emit the coverage at the process exit but still want to collect it on demand at some point. PR-URL: #33807 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Ben Coe <bencoe@gmail.com>
- Loading branch information
1 parent
15ffed5
commit 7bfa872
Showing
6 changed files
with
73 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
'use strict'; | ||
const v8 = require('v8'); | ||
v8.stopCoverage(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
'use strict'; | ||
|
||
if (!process.features.inspector) return; | ||
|
||
require('../common'); | ||
const fixtures = require('../common/fixtures'); | ||
const tmpdir = require('../common/tmpdir'); | ||
const assert = require('assert'); | ||
const fs = require('fs'); | ||
const { spawnSync } = require('child_process'); | ||
|
||
tmpdir.refresh(); | ||
const intervals = 20; | ||
|
||
{ | ||
const output = spawnSync(process.execPath, [ | ||
'-r', | ||
fixtures.path('v8-coverage', 'stop-coverage'), | ||
'-r', | ||
fixtures.path('v8-coverage', 'take-coverage'), | ||
fixtures.path('v8-coverage', 'interval'), | ||
], { | ||
env: { | ||
...process.env, | ||
NODE_V8_COVERAGE: tmpdir.path, | ||
NODE_DEBUG_NATIVE: 'INSPECTOR_PROFILER', | ||
TEST_INTERVALS: intervals | ||
}, | ||
}); | ||
console.log(output.stderr.toString()); | ||
assert.strictEqual(output.status, 0); | ||
const coverageFiles = fs.readdirSync(tmpdir.path); | ||
assert.strictEqual(coverageFiles.length, 0); | ||
} |