forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
src: stop the profiler and the inspector before snapshot serialization
Otherwise NODE_V8_COVERAGE would crash in snapshot tests because V8 cannot serialize the leftover debug infos. This ensures that we clean them all up before serialization. PR-URL: nodejs#51815 Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
- Loading branch information
1 parent
ef0e505
commit 6dd63ed
Showing
3 changed files
with
72 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
'use strict'; | ||
|
||
// This tests that the snapshot works with built-in coverage collection. | ||
|
||
const common = require('../common'); | ||
common.skipIfInspectorDisabled(); | ||
|
||
const { spawnSyncAndExitWithoutError } = require('../common/child_process'); | ||
const tmpdir = require('../common/tmpdir'); | ||
const fixtures = require('../common/fixtures'); | ||
const fs = require('fs'); | ||
const assert = require('assert'); | ||
|
||
tmpdir.refresh(); | ||
const blobPath = tmpdir.resolve('snapshot.blob'); | ||
const file = fixtures.path('empty.js'); | ||
|
||
function filterCoverageFiles(name) { | ||
return name.startsWith('coverage') && name.endsWith('.json'); | ||
} | ||
{ | ||
// Create the snapshot. | ||
const { child } = spawnSyncAndExitWithoutError(process.execPath, [ | ||
'--snapshot-blob', | ||
blobPath, | ||
'--build-snapshot', | ||
file, | ||
], { | ||
cwd: tmpdir.path, | ||
env: { | ||
...process.env, | ||
NODE_V8_COVERAGE: tmpdir.path, | ||
NODE_DEBUG_NATIVE: 'inspector_profiler', | ||
} | ||
}); | ||
const files = fs.readdirSync(tmpdir.path); | ||
console.log('Files in tmpdir.path', files); // Log for debugging the test. | ||
const coverage = files.filter(filterCoverageFiles); | ||
console.log(child.stderr.toString()); | ||
assert.strictEqual(coverage.length, 1); | ||
} | ||
|
||
{ | ||
const { child } = spawnSyncAndExitWithoutError(process.execPath, [ | ||
'--snapshot-blob', | ||
blobPath, | ||
file, | ||
], { | ||
cwd: tmpdir.path, | ||
env: { | ||
...process.env, | ||
NODE_V8_COVERAGE: tmpdir.path, | ||
NODE_DEBUG_NATIVE: 'inspector_profiler', | ||
}, | ||
}); | ||
const files = fs.readdirSync(tmpdir.path); | ||
console.log('Files in tmpdir.path', files); // Log for debugging the test. | ||
const coverage = files.filter(filterCoverageFiles); | ||
console.log(child.stderr.toString()); | ||
assert.strictEqual(coverage.length, 2); | ||
} |