Skip to content
Closed
Changes from 1 commit
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
Next Next commit
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 <cjihrig@gmail.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
thefourtheye committed Feb 5, 2017
commit 8f61ca9f03e7ee5f7d51946d64170e8d081b4d8c
20 changes: 10 additions & 10 deletions test/debugger/test-debugger-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ setTimeout(function() {

var resCount = 0;
var p = new debug.Protocol();
p.onResponse = function(res) {
p.onResponse = function() {
resCount++;
};

Expand Down Expand Up @@ -89,7 +89,7 @@ function addTest(cb) {
addTest(function(client, done) {
console.error('requesting version');
client.reqVersion(function(err, v) {
assert.ok(!err);
assert.ifError(err);
console.log('version: %s', v);
assert.strictEqual(process.versions.v8, v);
done();
Expand All @@ -99,13 +99,13 @@ addTest(function(client, done) {
addTest(function(client, done) {
console.error('requesting scripts');
client.reqScripts(function(err) {
assert.ok(!err);
assert.ifError(err);
console.error('got %d scripts', Object.keys(client.scripts).length);

var foundMainScript = false;
for (var k in client.scripts) {
var script = client.scripts[k];
if (script && script.name === 'node.js') {
if (script && script.name === 'bootstrap_node.js') {
foundMainScript = true;
break;
}
Expand All @@ -119,7 +119,7 @@ addTest(function(client, done) {
console.error('eval 2+2');
client.reqEval('2+2', function(err, res) {
console.error(res);
assert.ok(!err);
assert.ifError(err);
assert.strictEqual(res.text, '4');
assert.strictEqual(res.value, 4);
done();
Expand All @@ -137,7 +137,7 @@ function doTest(cb, done) {
var args = ['--debug=' + debugPort, '-e', script];
nodeProcess = spawn(process.execPath, args);

nodeProcess.stdout.once('data', function(c) {
nodeProcess.stdout.once('data', function() {
console.log('>>> new node process: %d', nodeProcess.pid);
var failed = true;
try {
Expand All @@ -158,7 +158,7 @@ function doTest(cb, done) {
console.error('got stderr data %j', data);
nodeProcess.stderr.resume();
b += data;
if (didTryConnect === false && b.match(/Debugger listening on port/)) {
if (didTryConnect === false && b.match(/Debugger listening on /)) {
didTryConnect = true;

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

function tryConnect() {
// Wait for some data before trying to connect
var c = new debug.Client();
const c = new debug.Client();
console.error('>>> connecting...');
c.connect(debug.port);
c.on('break', function(brk) {
c.on('break', function() {
c.reqContinue(function() {});
});
c.on('ready', function() {
Expand Down Expand Up @@ -199,7 +199,7 @@ function doTest(cb, done) {


function run() {
var t = tests[0];
const t = tests[0];
if (!t) return;

doTest(t, function() {
Expand Down