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)
This commit is contained in:
parent
e406613ee5
commit
39fec6003e
@ -785,7 +785,6 @@ function Interface(stdin, stdout, args) {
|
|||||||
this.breakpoints = [];
|
this.breakpoints = [];
|
||||||
|
|
||||||
// Run script automatically
|
// Run script automatically
|
||||||
this.clearline();
|
|
||||||
this.pause();
|
this.pause();
|
||||||
|
|
||||||
// XXX Need to figure out why we need this delay
|
// XXX Need to figure out why we need this delay
|
||||||
@ -827,6 +826,8 @@ Interface.prototype.clearline = function() {
|
|||||||
if (this.stdout.isTTY) {
|
if (this.stdout.isTTY) {
|
||||||
this.stdout.cursorTo(0);
|
this.stdout.cursorTo(0);
|
||||||
this.stdout.clearLine(1);
|
this.stdout.clearLine(1);
|
||||||
|
} else {
|
||||||
|
this.stdout.write('\b');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -876,7 +877,7 @@ Interface.prototype.handleBreak = function(r) {
|
|||||||
// And list source
|
// And list source
|
||||||
this.list(2);
|
this.list(2);
|
||||||
|
|
||||||
this.resume();
|
this.resume(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,8 +45,6 @@ var expected = [];
|
|||||||
child.on('line', function(line) {
|
child.on('line', function(line) {
|
||||||
assert.ok(expected.length > 0, 'Got unexpected line: ' + line);
|
assert.ok(expected.length > 0, 'Got unexpected line: ' + line);
|
||||||
|
|
||||||
console.log(JSON.stringify(line) + ',');
|
|
||||||
|
|
||||||
var expectedLine = expected[0].lines.shift();
|
var expectedLine = expected[0].lines.shift();
|
||||||
assert.equal(line, expectedLine);
|
assert.equal(line, expectedLine);
|
||||||
|
|
||||||
@ -72,45 +70,44 @@ function addTest(input, output) {
|
|||||||
|
|
||||||
// Initial lines
|
// Initial lines
|
||||||
addTest(null, [
|
addTest(null, [
|
||||||
"debug> < debugger listening on port 5858",
|
"debug> \b< debugger listening on port 5858",
|
||||||
"debug> connecting... ok",
|
"debug> \bconnecting... ok",
|
||||||
"debug> break in [unnamed]:3",
|
"debug> \bbreak in [unnamed]:3",
|
||||||
" 1 ",
|
"\b 1 ",
|
||||||
" 2 debugger;",
|
"\b 2 debugger;",
|
||||||
" 3 debugger;",
|
"\b 3 debugger;",
|
||||||
" 4 function a(x) {",
|
"\b 4 function a(x) {",
|
||||||
" 5 var i = 10;"
|
"\b 5 var i = 10;"
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Next
|
// Next
|
||||||
addTest('n', [
|
addTest('n', [
|
||||||
"debug> debug> debug> break in [unnamed]:13",
|
"debug> debug> debug> \bbreak in [unnamed]:13",
|
||||||
" 11 return [\"hello\", \"world\"].join(\" \");",
|
"\b 11 return ['hello', 'world'].join(' ');",
|
||||||
" 12 };",
|
"\b 12 };",
|
||||||
" 13 a();",
|
"\b 13 a();",
|
||||||
" 14 a(1);",
|
"\b 14 a(1);",
|
||||||
" 15 b();"
|
"\b 15 b();"
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Continue
|
// Continue
|
||||||
addTest('c', [
|
addTest('c', [
|
||||||
"debug> debug> debug> break in [unnamed]:7",
|
"debug> debug> debug> \bbreak in [unnamed]:7",
|
||||||
" 5 var i = 10;",
|
"\b 5 var i = 10;",
|
||||||
" 6 while (--i != 0);",
|
"\b 6 while (--i != 0);",
|
||||||
" 7 debugger;",
|
"\b 7 debugger;",
|
||||||
" 8 return i;",
|
"\b 8 return i;",
|
||||||
" 9 };"
|
"\b 9 };"
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
// Step out
|
// Step out
|
||||||
addTest('o', [
|
addTest('o', [
|
||||||
"debug> debug> debug> break in [unnamed]:14",
|
"debug> debug> debug> \bbreak in [unnamed]:14",
|
||||||
" 12 };",
|
"\b 12 };",
|
||||||
" 13 a();",
|
"\b 13 a();",
|
||||||
" 14 a(1);",
|
"\b 14 a(1);",
|
||||||
" 15 b();",
|
"\b 15 b();",
|
||||||
" 16 b();"
|
"\b 16 b();"
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
@ -130,9 +127,13 @@ setTimeout(function() {
|
|||||||
|
|
||||||
process.once('uncaughtException', function(e) {
|
process.once('uncaughtException', function(e) {
|
||||||
quit();
|
quit();
|
||||||
throw e;
|
console.error(e.toString());
|
||||||
|
process.exit(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
process.on('exit', function() {
|
process.on('exit', function(code) {
|
||||||
quit();
|
quit();
|
||||||
|
if (code === 0) {
|
||||||
|
assert.equal(expected.length, 0);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user