Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: change promises to async/await in test-debugger-heap-profiler #44693

Merged
merged 1 commit into from Sep 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 14 additions & 13 deletions test/sequential/test-debugger-heap-profiler.js
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());
}