Browse Source

debug repl tests: Add visibility, remove test that times out

The 'Can't backtrace now' message takes over 10 seconds to return.
That's too much time to have to wait for a test, and when it times
out, it was causing an orphaned node process.

This cleans up the node process, and also removes the test that's
timing out, so that the case is hit less often.

Todo: Make the backtrace message come back faster.
v0.9.1-release
isaacs 13 years ago
parent
commit
d2389f8fab
  1. 18
      test/simple/test-debugger-repl-utf8.js
  2. 21
      test/simple/test-debugger-repl.js

18
test/simple/test-debugger-repl-utf8.js

@ -31,6 +31,8 @@ var script = common.fixturesDir + '/breakpoints_utf8.js';
var child = spawn(process.execPath, ['debug', '--port=' + port, script]); var child = spawn(process.execPath, ['debug', '--port=' + port, script]);
console.error('./node', 'debug', '--port=' + port, script);
var buffer = ''; var buffer = '';
child.stdout.setEncoding('utf-8'); child.stdout.setEncoding('utf-8');
child.stdout.on('data', function(data) { child.stdout.on('data', function(data) {
@ -45,6 +47,8 @@ child.stderr.pipe(process.stdout);
var expected = []; var expected = [];
child.on('line', function(line) { child.on('line', function(line) {
line = line.replace(/^(debug> )+/, 'debug> ');
console.error('line> ' + line);
assert.ok(expected.length > 0, 'Got unexpected line: ' + line); assert.ok(expected.length > 0, 'Got unexpected line: ' + line);
var expectedLine = expected[0].lines.shift(); var expectedLine = expected[0].lines.shift();
@ -134,12 +138,6 @@ addTest('c', [
/\d/, /\d/, /\d/, /\d/, /\d/ /\d/, /\d/, /\d/, /\d/, /\d/
]); ]);
// Continue
addTest('c, bt', [
/Can't request backtrace now/
]);
function finish() { function finish() {
process.exit(0); process.exit(0);
} }
@ -151,18 +149,24 @@ function quit() {
} }
setTimeout(function() { setTimeout(function() {
console.error('dying badly');
var err = 'Timeout'; var err = 'Timeout';
if (expected.length > 0 && expected[0].lines) { if (expected.length > 0 && expected[0].lines) {
err = err + '. Expected: ' + expected[0].lines.shift(); err = err + '. Expected: ' + expected[0].lines.shift();
} }
quit();
child.kill('SIGKILL');
// give the sigkill time to work.
setTimeout(function() {
throw new Error(err); throw new Error(err);
}, 100);
}, 5000); }, 5000);
process.once('uncaughtException', function(e) { process.once('uncaughtException', function(e) {
quit(); quit();
console.error(e.toString()); console.error(e.toString());
child.kill('SIGKILL');
process.exit(1); process.exit(1);
}); });

21
test/simple/test-debugger-repl.js

@ -25,10 +25,13 @@ var assert = require('assert');
var spawn = require('child_process').spawn; var spawn = require('child_process').spawn;
var debug = require('_debugger'); var debug = require('_debugger');
var port = common.PORT + 1337;
var script = common.fixturesDir + '/breakpoints.js'; var script = common.fixturesDir + '/breakpoints.js';
var child = spawn(process.execPath, var child = spawn(process.execPath, ['debug', '--port=' + port, script]);
['debug', '--port=' + (common.PORT + 1337), script]);
console.error('./node', 'debug', '--port=' + port, script);
var buffer = ''; var buffer = '';
child.stdout.setEncoding('utf-8'); child.stdout.setEncoding('utf-8');
@ -44,6 +47,8 @@ child.stderr.pipe(process.stdout);
var expected = []; var expected = [];
child.on('line', function(line) { child.on('line', function(line) {
line = line.replace(/^(debug> )+/, 'debug> ');
console.error('line> ' + line);
assert.ok(expected.length > 0, 'Got unexpected line: ' + line); assert.ok(expected.length > 0, 'Got unexpected line: ' + line);
var expectedLine = expected[0].lines.shift(); var expectedLine = expected[0].lines.shift();
@ -138,12 +143,6 @@ addTest('c', [
/\d/, /\d/, /\d/, /\d/, /\d/ /\d/, /\d/, /\d/, /\d/, /\d/
]); ]);
// Continue
addTest('c, bt', [
/Can't request backtrace now/
]);
function finish() { function finish() {
process.exit(0); process.exit(0);
} }
@ -159,8 +158,14 @@ setTimeout(function() {
if (expected.length > 0 && expected[0].lines) { if (expected.length > 0 && expected[0].lines) {
err = err + '. Expected: ' + expected[0].lines.shift(); err = err + '. Expected: ' + expected[0].lines.shift();
} }
quit();
child.kill('SIGKILL');
// give the sigkill time to work.
setTimeout(function() {
throw new Error(err); throw new Error(err);
}, 100);
}, 5000); }, 5000);
process.once('uncaughtException', function(e) { process.once('uncaughtException', function(e) {

Loading…
Cancel
Save