-
Notifications
You must be signed in to change notification settings - Fork 29.1k
/
test-debugger-heap-profiler.js
39 lines (31 loc) · 1.11 KB
/
test-debugger-heap-profiler.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';
const common = require('../common');
common.skipIfInspectorDisabled();
const fixtures = require('../common/fixtures');
const startCLI = require('../common/debugger');
const tmpdir = require('../common/tmpdir');
const path = require('path');
tmpdir.refresh();
const { readFileSync } = require('fs');
const filename = path.join(tmpdir.path, 'node.heapsnapshot');
// Heap profiler take snapshot.
{
const opts = { cwd: tmpdir.path };
const cli = startCLI([fixtures.path('debugger/empty.js')], [], opts);
async function waitInitialBreak() {
try {
await cli.waitForInitialBreak();
await cli.waitForPrompt();
await cli.command('takeHeapSnapshot()');
JSON.parse(readFileSync(filename, 'utf8'));
// Check that two simultaneous snapshots don't step all over each other.
// Refs: https://github.com/nodejs/node/issues/39555
await cli.command('takeHeapSnapshot(); takeHeapSnapshot()');
JSON.parse(readFileSync(filename, 'utf8'));
} finally {
await cli.quit();
}
}
// Check that the snapshot is valid JSON.
waitInitialBreak().then(common.mustCall());
}