Skip to content

Commit d33e560

Browse files
thefourtheyeevanlucas
authored andcommitted
test: fix and improve debug-break-on-uncaught
This test runs based on a expectation that the stderr will get the string 'Debugger listening on port'. But the actual message printed to stderr has changed to 'Debugger listening on host:port'. So the the actuals tests did not even start and eventually timeout. Apart from that, changed `var`s to `let`s or `const`s. Refs: #10361 PR-URL: #10370 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: James M Snell <[email protected]
1 parent 9349f08 commit d33e560

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

test/debugger/test-debug-break-on-uncaught.js

+12-13
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const assert = require('assert');
55
const spawn = require('child_process').spawn;
66
const debug = require('_debugger');
77

8-
var scenarios = [];
8+
const scenarios = [];
99

1010
addScenario('global.js', 2);
1111
addScenario('timeout.js', 2);
@@ -21,34 +21,33 @@ function addScenario(scriptName, throwsOnLine) {
2121
}
2222

2323
function run() {
24-
var next = scenarios.shift();
24+
const next = scenarios.shift();
2525
if (next) next();
2626
}
2727

2828
function runScenario(scriptName, throwsOnLine, next) {
29-
console.log('**[ %s ]**', scriptName);
30-
var asserted = false;
31-
var port = common.PORT;
29+
let asserted = false;
30+
const port = common.PORT;
3231

33-
var testScript = path.join(
32+
const testScript = path.join(
3433
common.fixturesDir,
3534
'uncaught-exceptions',
3635
scriptName
3736
);
3837

39-
var child = spawn(process.execPath, [ '--debug-brk=' + port, testScript ]);
38+
const child = spawn(process.execPath, [ '--debug-brk=' + port, testScript ]);
4039
child.on('close', function() {
4140
assert(asserted, 'debugger did not pause on exception');
4241
if (next) next();
4342
});
4443

45-
var exceptions = [];
44+
const exceptions = [];
4645

47-
var stderr = '';
46+
let stderr = '';
4847

4948
function stderrListener(data) {
5049
stderr += data;
51-
if (stderr.includes('Debugger listening on port')) {
50+
if (stderr.includes('Debugger listening on ')) {
5251
setTimeout(setupClient.bind(null, runTest), 200);
5352
child.stderr.removeListener('data', stderrListener);
5453
}
@@ -58,7 +57,7 @@ function runScenario(scriptName, throwsOnLine, next) {
5857
child.stderr.on('data', stderrListener);
5958

6059
function setupClient(callback) {
61-
var client = new debug.Client();
60+
const client = new debug.Client();
6261

6362
client.once('ready', callback.bind(null, client));
6463

@@ -83,14 +82,14 @@ function runScenario(scriptName, throwsOnLine, next) {
8382
enabled: true
8483
}
8584
},
86-
function(error, result) {
85+
function(error) {
8786
assert.ifError(error);
8887

8988
client.on('exception', function(event) {
9089
exceptions.push(event.body);
9190
});
9291

93-
client.reqContinue(function(error, result) {
92+
client.reqContinue(function(error) {
9493
assert.ifError(error);
9594
setTimeout(assertHasPaused.bind(null, client), 100);
9695
});

0 commit comments

Comments
 (0)