Skip to content

Commit ddf0297

Browse files
brindashar4danielleadams
authored andcommitted
test: use async/await in test-debugger-heap-profiler
PR-URL: #44693 Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent e0fbba0 commit ddf0297

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

test/sequential/test-debugger-heap-profiler.js

+14-13
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,21 @@ const filename = path.join(tmpdir.path, 'node.heapsnapshot');
1919
const opts = { cwd: tmpdir.path };
2020
const cli = startCLI([fixtures.path('debugger/empty.js')], [], opts);
2121

22-
function onFatal(error) {
23-
cli.quit();
24-
throw error;
22+
async function waitInitialBreak() {
23+
try {
24+
await cli.waitForInitialBreak();
25+
await cli.waitForPrompt();
26+
await cli.command('takeHeapSnapshot()');
27+
JSON.parse(readFileSync(filename, 'utf8'));
28+
// Check that two simultaneous snapshots don't step all over each other.
29+
// Refs: https://github.com/nodejs/node/issues/39555
30+
await cli.command('takeHeapSnapshot(); takeHeapSnapshot()');
31+
JSON.parse(readFileSync(filename, 'utf8'));
32+
} finally {
33+
await cli.quit();
34+
}
2535
}
2636

2737
// Check that the snapshot is valid JSON.
28-
return cli.waitForInitialBreak()
29-
.then(() => cli.waitForPrompt())
30-
.then(() => cli.command('takeHeapSnapshot()'))
31-
.then(() => JSON.parse(readFileSync(filename, 'utf8')))
32-
// Check that two simultaneous snapshots don't step all over each other.
33-
// Refs: https://github.com/nodejs/node/issues/39555
34-
.then(() => cli.command('takeHeapSnapshot(); takeHeapSnapshot()'))
35-
.then(() => JSON.parse(readFileSync(filename, 'utf8')))
36-
.then(() => cli.quit())
37-
.then(null, onFatal);
38+
waitInitialBreak().then(common.mustCall());
3839
}

0 commit comments

Comments
 (0)