test: use ES6 in test-debugger-client.js
implements ES6 const and let instead var in test-debugger-client.js PR-URL: https://github.com/nodejs/node/pull/10183 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Italo A. Casas <me@italoacasas.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
This commit is contained in:
parent
a84017a689
commit
5607228099
@ -1,12 +1,12 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
var assert = require('assert');
|
const assert = require('assert');
|
||||||
var debug = require('_debugger');
|
const debug = require('_debugger');
|
||||||
|
|
||||||
process.env.NODE_DEBUGGER_TIMEOUT = 2000;
|
process.env.NODE_DEBUGGER_TIMEOUT = 2000;
|
||||||
var debugPort = common.PORT;
|
const debugPort = common.PORT;
|
||||||
debug.port = debugPort;
|
debug.port = debugPort;
|
||||||
var spawn = require('child_process').spawn;
|
const spawn = require('child_process').spawn;
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
if (nodeProcess) nodeProcess.kill('SIGTERM');
|
if (nodeProcess) nodeProcess.kill('SIGTERM');
|
||||||
@ -14,8 +14,8 @@ setTimeout(function() {
|
|||||||
}, 10000).unref();
|
}, 10000).unref();
|
||||||
|
|
||||||
|
|
||||||
var resCount = 0;
|
let resCount = 0;
|
||||||
var p = new debug.Protocol();
|
const p = new debug.Protocol();
|
||||||
p.onResponse = function(res) {
|
p.onResponse = function(res) {
|
||||||
resCount++;
|
resCount++;
|
||||||
};
|
};
|
||||||
@ -29,12 +29,12 @@ assert.strictEqual(resCount, 1);
|
|||||||
|
|
||||||
// Make sure split messages go in.
|
// Make sure split messages go in.
|
||||||
|
|
||||||
var parts = [];
|
const parts = [];
|
||||||
parts.push('Content-Length: 336\r\n');
|
parts.push('Content-Length: 336\r\n');
|
||||||
assert.strictEqual(parts[0].length, 21);
|
assert.strictEqual(parts[0].length, 21);
|
||||||
parts.push('\r\n');
|
parts.push('\r\n');
|
||||||
assert.strictEqual(parts[1].length, 2);
|
assert.strictEqual(parts[1].length, 2);
|
||||||
var bodyLength = 0;
|
let bodyLength = 0;
|
||||||
|
|
||||||
parts.push('{"seq":12,"type":"event","event":"break","body":' +
|
parts.push('{"seq":12,"type":"event","event":"break","body":' +
|
||||||
'{"invocationText":"#<a Server>');
|
'{"invocationText":"#<a Server>');
|
||||||
@ -55,7 +55,7 @@ bodyLength += parts[4].length;
|
|||||||
|
|
||||||
assert.strictEqual(bodyLength, 336);
|
assert.strictEqual(bodyLength, 336);
|
||||||
|
|
||||||
for (var i = 0; i < parts.length; i++) {
|
for (let i = 0; i < parts.length; i++) {
|
||||||
p.execute(parts[i]);
|
p.execute(parts[i]);
|
||||||
}
|
}
|
||||||
assert.strictEqual(resCount, 2);
|
assert.strictEqual(resCount, 2);
|
||||||
@ -63,24 +63,24 @@ assert.strictEqual(resCount, 2);
|
|||||||
|
|
||||||
// Make sure that if we get backed up, we still manage to get all the
|
// Make sure that if we get backed up, we still manage to get all the
|
||||||
// messages
|
// messages
|
||||||
var d = 'Content-Length: 466\r\n\r\n' +
|
const d = 'Content-Length: 466\r\n\r\n' +
|
||||||
'{"seq":10,"type":"event","event":"afterCompile","success":true,' +
|
'{"seq":10,"type":"event","event":"afterCompile","success":true,' +
|
||||||
'"body":{"script":{"handle":1,"type":"script","name":"dns.js",' +
|
'"body":{"script":{"handle":1,"type":"script","name":"dns.js",' +
|
||||||
'"id":34,"lineOffset":0,"columnOffset":0,"lineCount":241,' +
|
'"id":34,"lineOffset":0,"columnOffset":0,"lineCount":241,' +
|
||||||
'"sourceStart":"(function(module, exports, require) {' +
|
'"sourceStart":"(function(module, exports, require) {' +
|
||||||
'var dns = process.binding(\'cares\')' +
|
'var dns = process.binding(\'cares\')' +
|
||||||
';\\nvar ne","sourceLength":6137,"scriptType":2,"compilationType":0,' +
|
';\\nvar ne","sourceLength":6137,"scriptType":2,"compilationType"' +
|
||||||
'"context":{"ref":0},"text":"dns.js (lines: 241)"}},"refs":' +
|
':0,"context":{"ref":0},"text":"dns.js (lines: 241)"}},"refs":' +
|
||||||
'[{"handle":0' +
|
'[{"handle":0' +
|
||||||
',"type":"context","text":"#<a ContextMirror>"}],"running":true}' +
|
',"type":"context","text":"#<a ContextMirror>"}],"running":true}' +
|
||||||
'\r\n\r\nContent-Length: 119\r\n\r\n' +
|
'\r\n\r\nContent-Length: 119\r\n\r\n' +
|
||||||
'{"seq":11,"type":"event","event":"scriptCollected","success":true,' +
|
'{"seq":11,"type":"event","event":"scriptCollected","success":true' +
|
||||||
'"body":{"script":{"id":26}},"refs":[],"running":true}';
|
',"body":{"script":{"id":26}},"refs":[],"running":true}';
|
||||||
p.execute(d);
|
p.execute(d);
|
||||||
assert.strictEqual(resCount, 4);
|
assert.strictEqual(resCount, 4);
|
||||||
|
|
||||||
var expectedConnections = 0;
|
let expectedConnections = 0;
|
||||||
var tests = [];
|
const tests = [];
|
||||||
function addTest(cb) {
|
function addTest(cb) {
|
||||||
expectedConnections++;
|
expectedConnections++;
|
||||||
tests.push(cb);
|
tests.push(cb);
|
||||||
@ -102,9 +102,9 @@ addTest(function(client, done) {
|
|||||||
assert.ok(!err);
|
assert.ok(!err);
|
||||||
console.error('got %d scripts', Object.keys(client.scripts).length);
|
console.error('got %d scripts', Object.keys(client.scripts).length);
|
||||||
|
|
||||||
var foundMainScript = false;
|
let foundMainScript = false;
|
||||||
for (var k in client.scripts) {
|
for (const k in client.scripts) {
|
||||||
var script = client.scripts[k];
|
const script = client.scripts[k];
|
||||||
if (script && script.name === 'node.js') {
|
if (script && script.name === 'node.js') {
|
||||||
foundMainScript = true;
|
foundMainScript = true;
|
||||||
break;
|
break;
|
||||||
@ -127,19 +127,19 @@ addTest(function(client, done) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
var connectCount = 0;
|
let connectCount = 0;
|
||||||
var script = 'setTimeout(function() { console.log("blah"); });' +
|
const script = 'setTimeout(function() { console.log("blah"); });' +
|
||||||
'setInterval(function() {}, 1000000);';
|
'setInterval(function() {}, 1000000);';
|
||||||
|
|
||||||
var nodeProcess;
|
let nodeProcess;
|
||||||
|
|
||||||
function doTest(cb, done) {
|
function doTest(cb, done) {
|
||||||
var args = ['--debug=' + debugPort, '-e', script];
|
const args = ['--debug=' + debugPort, '-e', script];
|
||||||
nodeProcess = spawn(process.execPath, args);
|
nodeProcess = spawn(process.execPath, args);
|
||||||
|
|
||||||
nodeProcess.stdout.once('data', function(c) {
|
nodeProcess.stdout.once('data', function(c) {
|
||||||
console.log('>>> new node process: %d', nodeProcess.pid);
|
console.log('>>> new node process: %d', nodeProcess.pid);
|
||||||
var failed = true;
|
let failed = true;
|
||||||
try {
|
try {
|
||||||
process._debugProcess(nodeProcess.pid);
|
process._debugProcess(nodeProcess.pid);
|
||||||
failed = false;
|
failed = false;
|
||||||
@ -151,9 +151,9 @@ function doTest(cb, done) {
|
|||||||
console.log('>>> starting debugger session');
|
console.log('>>> starting debugger session');
|
||||||
});
|
});
|
||||||
|
|
||||||
var didTryConnect = false;
|
let didTryConnect = false;
|
||||||
nodeProcess.stderr.setEncoding('utf8');
|
nodeProcess.stderr.setEncoding('utf8');
|
||||||
var b = '';
|
let b = '';
|
||||||
nodeProcess.stderr.on('data', function(data) {
|
nodeProcess.stderr.on('data', function(data) {
|
||||||
console.error('got stderr data %j', data);
|
console.error('got stderr data %j', data);
|
||||||
nodeProcess.stderr.resume();
|
nodeProcess.stderr.resume();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user