From d2389f8fab22e2ce187551addde3b18730030af5 Mon Sep 17 00:00:00 2001 From: isaacs Date: Tue, 20 Mar 2012 19:48:07 -0700 Subject: [PATCH] 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. --- test/simple/test-debugger-repl-utf8.js | 20 ++++++++++++-------- test/simple/test-debugger-repl.js | 23 ++++++++++++++--------- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/test/simple/test-debugger-repl-utf8.js b/test/simple/test-debugger-repl-utf8.js index 851a02d032..e141913605 100644 --- a/test/simple/test-debugger-repl-utf8.js +++ b/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]); +console.error('./node', 'debug', '--port=' + port, script); + var buffer = ''; child.stdout.setEncoding('utf-8'); child.stdout.on('data', function(data) { @@ -45,6 +47,8 @@ child.stderr.pipe(process.stdout); var expected = []; child.on('line', function(line) { + line = line.replace(/^(debug> )+/, 'debug> '); + console.error('line> ' + line); assert.ok(expected.length > 0, 'Got unexpected line: ' + line); var expectedLine = expected[0].lines.shift(); @@ -134,12 +138,6 @@ addTest('c', [ /\d/, /\d/, /\d/, /\d/, /\d/ ]); -// Continue -addTest('c, bt', [ - /Can't request backtrace now/ -]); - - function finish() { process.exit(0); } @@ -151,18 +149,24 @@ function quit() { } setTimeout(function() { + console.error('dying badly'); var err = 'Timeout'; if (expected.length > 0 && expected[0].lines) { err = err + '. Expected: ' + expected[0].lines.shift(); } + quit(); + child.kill('SIGKILL'); + + // give the sigkill time to work. + setTimeout(function() { + throw new Error(err); + }, 100); - throw new Error(err); }, 5000); process.once('uncaughtException', function(e) { quit(); console.error(e.toString()); - child.kill('SIGKILL'); process.exit(1); }); diff --git a/test/simple/test-debugger-repl.js b/test/simple/test-debugger-repl.js index e62847f343..19ff12e3cd 100644 --- a/test/simple/test-debugger-repl.js +++ b/test/simple/test-debugger-repl.js @@ -25,10 +25,13 @@ var assert = require('assert'); var spawn = require('child_process').spawn; var debug = require('_debugger'); +var port = common.PORT + 1337; + var script = common.fixturesDir + '/breakpoints.js'; -var child = spawn(process.execPath, - ['debug', '--port=' + (common.PORT + 1337), script]); +var child = spawn(process.execPath, ['debug', '--port=' + port, script]); + +console.error('./node', 'debug', '--port=' + port, script); var buffer = ''; child.stdout.setEncoding('utf-8'); @@ -44,6 +47,8 @@ child.stderr.pipe(process.stdout); var expected = []; child.on('line', function(line) { + line = line.replace(/^(debug> )+/, 'debug> '); + console.error('line> ' + line); assert.ok(expected.length > 0, 'Got unexpected line: ' + line); var expectedLine = expected[0].lines.shift(); @@ -138,12 +143,6 @@ addTest('c', [ /\d/, /\d/, /\d/, /\d/, /\d/ ]); -// Continue -addTest('c, bt', [ - /Can't request backtrace now/ -]); - - function finish() { process.exit(0); } @@ -159,8 +158,14 @@ setTimeout(function() { if (expected.length > 0 && expected[0].lines) { err = err + '. Expected: ' + expected[0].lines.shift(); } + quit(); + child.kill('SIGKILL'); + + // give the sigkill time to work. + setTimeout(function() { + throw new Error(err); + }, 100); - throw new Error(err); }, 5000); process.once('uncaughtException', function(e) {