Skip to content

Commit

Permalink
test: use async/await in test-debugger-heap-profiler
Browse files Browse the repository at this point in the history
PR-URL: #44693
Reviewed-By: Rich Trott <[email protected]>
  • Loading branch information
brindashar4 authored and Trott committed Sep 29, 2022
1 parent d6c2316 commit 865a578
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions test/sequential/test-debugger-heap-profiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,21 @@ const filename = path.join(tmpdir.path, 'node.heapsnapshot');
const opts = { cwd: tmpdir.path };
const cli = startCLI([fixtures.path('debugger/empty.js')], [], opts);

function onFatal(error) {
cli.quit();
throw error;
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.
return cli.waitForInitialBreak()
.then(() => cli.waitForPrompt())
.then(() => cli.command('takeHeapSnapshot()'))
.then(() => 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
.then(() => cli.command('takeHeapSnapshot(); takeHeapSnapshot()'))
.then(() => JSON.parse(readFileSync(filename, 'utf8')))
.then(() => cli.quit())
.then(null, onFatal);
waitInitialBreak().then(common.mustCall());
}

0 comments on commit 865a578

Please sign in to comment.