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:update promise to async/await test-debugger-preserve-breaks #44696

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 32 additions & 47 deletions test/sequential/test-debugger-preserve-breaks.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,54 +9,39 @@ const startCLI = require('../common/debugger');
const assert = require('assert');
const path = require('path');

const scriptFullPath = fixtures.path('debugger', 'three-lines.js');
const script = path.relative(process.cwd(), scriptFullPath);

// Run after quit.
{
const scriptFullPath = fixtures.path('debugger', 'three-lines.js');
const script = path.relative(process.cwd(), scriptFullPath);
const runTest = async () => {
const cli = startCLI([script]);

function onFatal(error) {
cli.quit();
throw error;
try {
await cli.waitForInitialBreak();
await cli.waitForPrompt();
await cli.command('breakpoints');
assert.match(cli.output, /No breakpoints yet/);
await cli.command('sb(2)');
await cli.command('sb(3)');
await cli.command('breakpoints');
assert.ok(cli.output.includes(`#0 ${script}:2`));
assert.ok(cli.output.includes(`#1 ${script}:3`));
await cli.stepCommand('c'); // hit line 2
await cli.stepCommand('c'); // hit line 3
assert.deepStrictEqual(cli.breakInfo, { filename: script, line: 3 });
await cli.command('restart');
await cli.waitForInitialBreak();
assert.deepStrictEqual(cli.breakInfo, { filename: script, line: 1 });
await cli.stepCommand('c');
assert.deepStrictEqual(cli.breakInfo, { filename: script, line: 2 });
await cli.stepCommand('c');
assert.deepStrictEqual(cli.breakInfo, { filename: script, line: 3 });
await cli.command('breakpoints');
const msg = `SCRIPT: ${script}, OUTPUT: ${cli.output}`;
assert.ok(cli.output.includes(`#0 ${script}:2`), msg);
assert.ok(cli.output.includes(`#1 ${script}:3`), msg);
} finally {
await cli.quit();
}
};

return cli.waitForInitialBreak()
.then(() => cli.waitForPrompt())
.then(() => cli.command('breakpoints'))
.then(() => {
assert.match(cli.output, /No breakpoints yet/);
})
.then(() => cli.command('sb(2)'))
.then(() => cli.command('sb(3)'))
.then(() => cli.command('breakpoints'))
.then(() => {
assert.ok(cli.output.includes(`#0 ${script}:2`));
assert.ok(cli.output.includes(`#1 ${script}:3`));
})
.then(() => cli.stepCommand('c')) // hit line 2
.then(() => cli.stepCommand('c')) // hit line 3
.then(() => {
assert.deepStrictEqual(cli.breakInfo, { filename: script, line: 3 });
})
.then(() => cli.command('restart'))
.then(() => cli.waitForInitialBreak())
.then(() => {
assert.deepStrictEqual(cli.breakInfo, { filename: script, line: 1 });
})
.then(() => cli.stepCommand('c'))
.then(() => {
assert.deepStrictEqual(cli.breakInfo, { filename: script, line: 2 });
})
.then(() => cli.stepCommand('c'))
.then(() => {
assert.deepStrictEqual(cli.breakInfo, { filename: script, line: 3 });
})
.then(() => cli.command('breakpoints'))
.then(() => {
const msg = `SCRIPT: ${script}, OUTPUT: ${cli.output}`;
assert.ok(cli.output.includes(`#0 ${script}:2`), msg);
assert.ok(cli.output.includes(`#1 ${script}:3`), msg);
})
.then(() => cli.quit())
.then(null, onFatal);
}
runTest();