-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
/
Copy pathtest-get-heapsnapshot-options.js
39 lines (33 loc) · 1.15 KB
/
test-get-heapsnapshot-options.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
'use strict';
// Flags: --expose-internals
require('../common');
const { getHeapSnapshotOptionTests, recordState } = require('../common/heap');
const tests = getHeapSnapshotOptionTests();
if (process.argv[2] === 'child') {
const { getHeapSnapshot } = require('v8');
require(tests.fixtures);
const { options, expected } = tests.cases[parseInt(process.argv[3])];
const snapshot = recordState(getHeapSnapshot(options));
console.log('Snapshot nodes', snapshot.snapshot.length);
console.log('Searching for', expected[0].children);
tests.check(snapshot, expected);
delete globalThis.obj; // To pass the leaked global tests.
return;
}
const { spawnSync } = require('child_process');
const assert = require('assert');
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
for (let i = 0; i < tests.cases.length; ++i) {
const child = spawnSync(
process.execPath,
['--expose-internals', __filename, 'child', i + ''],
{
cwd: tmpdir.path
});
const stderr = child.stderr.toString();
const stdout = child.stdout.toString();
console.log('[STDERR]', stderr);
console.log('[STDOUT]', stdout);
assert.strictEqual(child.status, 0);
}