From 39fec6003e2cd52dfcd4e25f6da7f6e54617630d Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Sat, 24 Sep 2011 01:48:04 +0700 Subject: [PATCH] debugger: remove useless clearlines, updated test * remove useless clearline call at Interface start * silence after .handleBreak() * output '\b' if this.stdout is not a tty (debugger) * add '\b' checks for clearline (test) --- lib/_debugger.js | 5 ++-- test/simple/test-debugger-repl.js | 63 ++++++++++++++++++++------------------- 2 files changed, 35 insertions(+), 33 deletions(-) diff --git a/lib/_debugger.js b/lib/_debugger.js index 73abad0..f8b69bf 100644 --- a/lib/_debugger.js +++ b/lib/_debugger.js @@ -785,7 +785,6 @@ function Interface(stdin, stdout, args) { this.breakpoints = []; // Run script automatically - this.clearline(); this.pause(); // XXX Need to figure out why we need this delay @@ -827,6 +826,8 @@ Interface.prototype.clearline = function() { if (this.stdout.isTTY) { this.stdout.cursorTo(0); this.stdout.clearLine(1); + } else { + this.stdout.write('\b'); } }; @@ -876,7 +877,7 @@ Interface.prototype.handleBreak = function(r) { // And list source this.list(2); - this.resume(); + this.resume(true); }; diff --git a/test/simple/test-debugger-repl.js b/test/simple/test-debugger-repl.js index 9d96993..ea2aed9 100644 --- a/test/simple/test-debugger-repl.js +++ b/test/simple/test-debugger-repl.js @@ -45,8 +45,6 @@ var expected = []; child.on('line', function(line) { assert.ok(expected.length > 0, 'Got unexpected line: ' + line); - console.log(JSON.stringify(line) + ','); - var expectedLine = expected[0].lines.shift(); assert.equal(line, expectedLine); @@ -72,45 +70,44 @@ function addTest(input, output) { // Initial lines addTest(null, [ - "debug> < debugger listening on port 5858", - "debug> connecting... ok", - "debug> break in [unnamed]:3", - " 1 ", - " 2 debugger;", - " 3 debugger;", - " 4 function a(x) {", - " 5 var i = 10;" + "debug> \b< debugger listening on port 5858", + "debug> \bconnecting... ok", + "debug> \bbreak in [unnamed]:3", + "\b 1 ", + "\b 2 debugger;", + "\b 3 debugger;", + "\b 4 function a(x) {", + "\b 5 var i = 10;" ]); // Next addTest('n', [ - "debug> debug> debug> break in [unnamed]:13", - " 11 return [\"hello\", \"world\"].join(\" \");", - " 12 };", - " 13 a();", - " 14 a(1);", - " 15 b();" + "debug> debug> debug> \bbreak in [unnamed]:13", + "\b 11 return ['hello', 'world'].join(' ');", + "\b 12 };", + "\b 13 a();", + "\b 14 a(1);", + "\b 15 b();" ]); // Continue addTest('c', [ - "debug> debug> debug> break in [unnamed]:7", - " 5 var i = 10;", - " 6 while (--i != 0);", - " 7 debugger;", - " 8 return i;", - " 9 };" + "debug> debug> debug> \bbreak in [unnamed]:7", + "\b 5 var i = 10;", + "\b 6 while (--i != 0);", + "\b 7 debugger;", + "\b 8 return i;", + "\b 9 };" ]); - // Step out addTest('o', [ - "debug> debug> debug> break in [unnamed]:14", - " 12 };", - " 13 a();", - " 14 a(1);", - " 15 b();", - " 16 b();" + "debug> debug> debug> \bbreak in [unnamed]:14", + "\b 12 };", + "\b 13 a();", + "\b 14 a(1);", + "\b 15 b();", + "\b 16 b();" ]); @@ -130,9 +127,13 @@ setTimeout(function() { process.once('uncaughtException', function(e) { quit(); - throw e; + console.error(e.toString()); + process.exit(1); }); -process.on('exit', function() { +process.on('exit', function(code) { quit(); + if (code === 0) { + assert.equal(expected.length, 0); + } }); -- 2.7.4