mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
b872d30d19
Support configuration of the HeapSnapshotMode and NumericsMode fields inf HeapSnapshotOptions in the JS APIs for heap snapshots. PR-URL: https://github.com/nodejs/node/pull/44989 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
40 lines
1.2 KiB
JavaScript
40 lines
1.2 KiB
JavaScript
'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);
|
|
}
|