Skip to content

Commit 9226bc3

Browse files
committed
test: add test for debugger restart message issue
Running "restart" in the debugger confusingly prints an out-of-date "Debugger listening on..." message before printing a second updated one. Refs: #39272
1 parent 4de6f20 commit 9226bc3

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
'use strict';
2+
3+
// Refs: https://github.com/nodejs/node/issues/39272
4+
5+
require('../common');
6+
7+
const assert = require('assert');
8+
9+
// When this is moved out of known_issues, this can be removed and replaced with
10+
// the commented-out use of common.skipIfInspectorDisabled() below.
11+
if (!process.features.inspector) {
12+
assert.fail('Known issues test should fail, so if the inspector is disabled');
13+
}
14+
15+
// Will need to uncomment this (and assign `common` above) when moved out of
16+
// known_issues.
17+
// common.skipIfInspectorDisabled();
18+
19+
// This can be reduced to 2 or even 1 (and the loop removed) once the debugger
20+
// is fixed. It's set higher to make sure that the error is tripped reliably
21+
// in CI. On most systems, the error will be tripped on the first test, but
22+
// on a few platforms in CI, it needs to be many times.
23+
const RESTARTS = 128;
24+
25+
const fixtures = require('../common/fixtures');
26+
const startCLI = require('../common/debugger');
27+
28+
// Using `restart` should result in only one "Connect/For help" message.
29+
{
30+
const script = fixtures.path('debugger', 'three-lines.js');
31+
const cli = startCLI([script]);
32+
33+
function onFatal(error) {
34+
cli.quit();
35+
throw error;
36+
}
37+
38+
const listeningRegExp = /Debugger listening on/g;
39+
40+
cli.waitForInitialBreak()
41+
.then(() => cli.waitForPrompt())
42+
.then(() => {
43+
assert.strictEqual(cli.output.match(listeningRegExp).length, 1);
44+
})
45+
.then(async () => {
46+
for (let i = 0; i < RESTARTS; i++) {
47+
await cli.stepCommand('restart');
48+
assert.strictEqual(cli.output.match(listeningRegExp).length, 1);
49+
}
50+
})
51+
.then(() => cli.quit())
52+
.then(null, onFatal);
53+
}

0 commit comments

Comments
 (0)