Skip to content

Commit 94a894a

Browse files
thefourtheyeevanlucas
authored andcommitted
test: fix and improve debugger-client test
This test expects the string 'Debugger listening on port' on stderr and since the message has been changed to 'Debugger listening on host:port' this was failing always. Apart from that, this test expects the main script's name to be `src/node.js`, but that has been renamed to `lib/internal/node.js` and then to `lib/internal/bootstrap_node.js`. So, the script name has been updated. Apart from that, using `const` instead of `var` wherever possible. Refer: #10361 PR-URL: #10371 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Sam Roberts <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 9ce28ec commit 94a894a

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

test/debugger/test-debugger-client.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ setTimeout(function() {
1616

1717
let resCount = 0;
1818
const p = new debug.Protocol();
19-
p.onResponse = function(res) {
19+
p.onResponse = function() {
2020
resCount++;
2121
};
2222

@@ -89,7 +89,7 @@ function addTest(cb) {
8989
addTest(function(client, done) {
9090
console.error('requesting version');
9191
client.reqVersion(function(err, v) {
92-
assert.ok(!err);
92+
assert.ifError(err);
9393
console.log('version: %s', v);
9494
assert.strictEqual(process.versions.v8, v);
9595
done();
@@ -99,13 +99,13 @@ addTest(function(client, done) {
9999
addTest(function(client, done) {
100100
console.error('requesting scripts');
101101
client.reqScripts(function(err) {
102-
assert.ok(!err);
102+
assert.ifError(err);
103103
console.error('got %d scripts', Object.keys(client.scripts).length);
104104

105105
let foundMainScript = false;
106106
for (const k in client.scripts) {
107107
const script = client.scripts[k];
108-
if (script && script.name === 'node.js') {
108+
if (script && script.name === 'bootstrap_node.js') {
109109
foundMainScript = true;
110110
break;
111111
}
@@ -119,7 +119,7 @@ addTest(function(client, done) {
119119
console.error('eval 2+2');
120120
client.reqEval('2+2', function(err, res) {
121121
console.error(res);
122-
assert.ok(!err);
122+
assert.ifError(err);
123123
assert.strictEqual(res.text, '4');
124124
assert.strictEqual(res.value, 4);
125125
done();
@@ -137,7 +137,7 @@ function doTest(cb, done) {
137137
const args = ['--debug=' + debugPort, '-e', script];
138138
nodeProcess = spawn(process.execPath, args);
139139

140-
nodeProcess.stdout.once('data', function(c) {
140+
nodeProcess.stdout.once('data', function() {
141141
console.log('>>> new node process: %d', nodeProcess.pid);
142142
let failed = true;
143143
try {
@@ -158,7 +158,7 @@ function doTest(cb, done) {
158158
console.error('got stderr data %j', data);
159159
nodeProcess.stderr.resume();
160160
b += data;
161-
if (didTryConnect === false && b.match(/Debugger listening on port/)) {
161+
if (didTryConnect === false && b.match(/Debugger listening on /)) {
162162
didTryConnect = true;
163163

164164
// The timeout is here to expose a race in the bootstrap process.
@@ -168,10 +168,10 @@ function doTest(cb, done) {
168168

169169
function tryConnect() {
170170
// Wait for some data before trying to connect
171-
var c = new debug.Client();
171+
const c = new debug.Client();
172172
console.error('>>> connecting...');
173173
c.connect(debug.port);
174-
c.on('break', function(brk) {
174+
c.on('break', function() {
175175
c.reqContinue(function() {});
176176
});
177177
c.on('ready', function() {
@@ -199,7 +199,7 @@ function doTest(cb, done) {
199199

200200

201201
function run() {
202-
var t = tests[0];
202+
const t = tests[0];
203203
if (!t) return;
204204

205205
doTest(t, function() {

0 commit comments

Comments
 (0)