Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cca2535

Browse filesBrowse files
poorvitusamdanielleadams
authored andcommitted
test: use async/await in test-debugger-preserve-breaks
PR-URL: #44696 Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent 0b2e8b1 commit cca2535
Copy full SHA for cca2535

File tree

Expand file treeCollapse file tree

1 file changed

+32
-47
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+32
-47
lines changed
Open diff view settings
Collapse file

‎test/sequential/test-debugger-preserve-breaks.js‎

Copy file name to clipboardExpand all lines: test/sequential/test-debugger-preserve-breaks.js
+32-47Lines changed: 32 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -9,54 +9,39 @@ const startCLI = require('../common/debugger');
99
const assert = require('assert');
1010
const path = require('path');
1111

12+
const scriptFullPath = fixtures.path('debugger', 'three-lines.js');
13+
const script = path.relative(process.cwd(), scriptFullPath);
14+
1215
// Run after quit.
13-
{
14-
const scriptFullPath = fixtures.path('debugger', 'three-lines.js');
15-
const script = path.relative(process.cwd(), scriptFullPath);
16+
const runTest = async () => {
1617
const cli = startCLI([script]);
17-
18-
function onFatal(error) {
19-
cli.quit();
20-
throw error;
18+
try {
19+
await cli.waitForInitialBreak();
20+
await cli.waitForPrompt();
21+
await cli.command('breakpoints');
22+
assert.match(cli.output, /No breakpoints yet/);
23+
await cli.command('sb(2)');
24+
await cli.command('sb(3)');
25+
await cli.command('breakpoints');
26+
assert.ok(cli.output.includes(`#0 ${script}:2`));
27+
assert.ok(cli.output.includes(`#1 ${script}:3`));
28+
await cli.stepCommand('c'); // hit line 2
29+
await cli.stepCommand('c'); // hit line 3
30+
assert.deepStrictEqual(cli.breakInfo, { filename: script, line: 3 });
31+
await cli.command('restart');
32+
await cli.waitForInitialBreak();
33+
assert.deepStrictEqual(cli.breakInfo, { filename: script, line: 1 });
34+
await cli.stepCommand('c');
35+
assert.deepStrictEqual(cli.breakInfo, { filename: script, line: 2 });
36+
await cli.stepCommand('c');
37+
assert.deepStrictEqual(cli.breakInfo, { filename: script, line: 3 });
38+
await cli.command('breakpoints');
39+
const msg = `SCRIPT: ${script}, OUTPUT: ${cli.output}`;
40+
assert.ok(cli.output.includes(`#0 ${script}:2`), msg);
41+
assert.ok(cli.output.includes(`#1 ${script}:3`), msg);
42+
} finally {
43+
await cli.quit();
2144
}
45+
};
2246

23-
return cli.waitForInitialBreak()
24-
.then(() => cli.waitForPrompt())
25-
.then(() => cli.command('breakpoints'))
26-
.then(() => {
27-
assert.match(cli.output, /No breakpoints yet/);
28-
})
29-
.then(() => cli.command('sb(2)'))
30-
.then(() => cli.command('sb(3)'))
31-
.then(() => cli.command('breakpoints'))
32-
.then(() => {
33-
assert.ok(cli.output.includes(`#0 ${script}:2`));
34-
assert.ok(cli.output.includes(`#1 ${script}:3`));
35-
})
36-
.then(() => cli.stepCommand('c')) // hit line 2
37-
.then(() => cli.stepCommand('c')) // hit line 3
38-
.then(() => {
39-
assert.deepStrictEqual(cli.breakInfo, { filename: script, line: 3 });
40-
})
41-
.then(() => cli.command('restart'))
42-
.then(() => cli.waitForInitialBreak())
43-
.then(() => {
44-
assert.deepStrictEqual(cli.breakInfo, { filename: script, line: 1 });
45-
})
46-
.then(() => cli.stepCommand('c'))
47-
.then(() => {
48-
assert.deepStrictEqual(cli.breakInfo, { filename: script, line: 2 });
49-
})
50-
.then(() => cli.stepCommand('c'))
51-
.then(() => {
52-
assert.deepStrictEqual(cli.breakInfo, { filename: script, line: 3 });
53-
})
54-
.then(() => cli.command('breakpoints'))
55-
.then(() => {
56-
const msg = `SCRIPT: ${script}, OUTPUT: ${cli.output}`;
57-
assert.ok(cli.output.includes(`#0 ${script}:2`), msg);
58-
assert.ok(cli.output.includes(`#1 ${script}:3`), msg);
59-
})
60-
.then(() => cli.quit())
61-
.then(null, onFatal);
62-
}
47+
runTest();

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.