debugger: test repeating last command
* debugger: Add NODE_FORCE_READLINE environment variable, handle `SIGINT`'s sent to process while in this mode.
This commit is contained in:
parent
8ac1a73635
commit
d68c02e3fe
@ -759,6 +759,15 @@ function Interface(stdin, stdout, args) {
|
|||||||
};
|
};
|
||||||
if (parseInt(process.env['NODE_NO_READLINE'], 10)) {
|
if (parseInt(process.env['NODE_NO_READLINE'], 10)) {
|
||||||
opts.terminal = false;
|
opts.terminal = false;
|
||||||
|
} else if (parseInt(process.env['NODE_FORCE_READLINE'], 10)) {
|
||||||
|
opts.terminal = true;
|
||||||
|
|
||||||
|
// Emulate Ctrl+C if we're emulating terminal
|
||||||
|
if (!this.stdout.isTTY) {
|
||||||
|
process.on('SIGINT', function() {
|
||||||
|
self.repl.rli.emit('SIGINT');
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (parseInt(process.env['NODE_DISABLE_COLORS'], 10)) {
|
if (parseInt(process.env['NODE_DISABLE_COLORS'], 10)) {
|
||||||
opts.useColors = false;
|
opts.useColors = false;
|
||||||
@ -777,7 +786,6 @@ function Interface(stdin, stdout, args) {
|
|||||||
self.killChild();
|
self.killChild();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
var proto = Interface.prototype,
|
var proto = Interface.prototype,
|
||||||
ignored = ['pause', 'resume', 'exitRepl', 'handleBreak',
|
ignored = ['pause', 'resume', 'exitRepl', 'handleBreak',
|
||||||
'requireConnection', 'killChild', 'trySpawn',
|
'requireConnection', 'killChild', 'trySpawn',
|
||||||
|
@ -29,7 +29,9 @@ var port = common.PORT + 1337;
|
|||||||
|
|
||||||
var script = common.fixturesDir + '/breakpoints.js';
|
var script = common.fixturesDir + '/breakpoints.js';
|
||||||
|
|
||||||
var child = spawn(process.execPath, ['debug', '--port=' + port, script]);
|
var child = spawn(process.execPath, ['debug', '--port=' + port, script], {
|
||||||
|
env: { NODE_FORCE_READLINE: 1 }
|
||||||
|
});
|
||||||
|
|
||||||
console.error('./node', 'debug', '--port=' + port, script);
|
console.error('./node', 'debug', '--port=' + port, script);
|
||||||
|
|
||||||
@ -48,6 +50,7 @@ var expected = [];
|
|||||||
|
|
||||||
child.on('line', function(line) {
|
child.on('line', function(line) {
|
||||||
line = line.replace(/^(debug> )+/, 'debug> ');
|
line = line.replace(/^(debug> )+/, 'debug> ');
|
||||||
|
line = line.replace(/\u001b\[\d+\w/g, '');
|
||||||
console.error('line> ' + line);
|
console.error('line> ' + line);
|
||||||
assert.ok(expected.length > 0, 'Got unexpected line: ' + line);
|
assert.ok(expected.length > 0, 'Got unexpected line: ' + line);
|
||||||
|
|
||||||
@ -96,15 +99,17 @@ addTest(null, [
|
|||||||
|
|
||||||
// Next
|
// Next
|
||||||
addTest('n', [
|
addTest('n', [
|
||||||
|
/debug> n/,
|
||||||
/break in .*:11/,
|
/break in .*:11/,
|
||||||
/9/, /10/, /11/, /12/, /13/
|
/9/, /10/, /11/, /12/, /13/
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Watch
|
// Watch
|
||||||
addTest('watch("\'x\'"), true', [/true/]);
|
addTest('watch("\'x\'"), true', [/debug>/, /true/]);
|
||||||
|
|
||||||
// Continue
|
// Continue
|
||||||
addTest('c', [
|
addTest('c', [
|
||||||
|
/debug>/,
|
||||||
/break in .*:5/,
|
/break in .*:5/,
|
||||||
/Watchers/,
|
/Watchers/,
|
||||||
/0:\s+'x' = "x"/,
|
/0:\s+'x' = "x"/,
|
||||||
@ -114,49 +119,64 @@ addTest('c', [
|
|||||||
|
|
||||||
// Show watchers
|
// Show watchers
|
||||||
addTest('watchers', [
|
addTest('watchers', [
|
||||||
|
/debug>/,
|
||||||
/0:\s+'x' = "x"/
|
/0:\s+'x' = "x"/
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Unwatch
|
// Unwatch
|
||||||
addTest('unwatch("\'x\'"), true', [/true/]);
|
addTest('unwatch("\'x\'"), true', [/debug>/, /true/]);
|
||||||
|
|
||||||
// Step out
|
// Step out
|
||||||
addTest('o', [
|
addTest('o', [
|
||||||
|
/debug>/,
|
||||||
/break in .*:12/,
|
/break in .*:12/,
|
||||||
/10/, /11/, /12/, /13/, /14/
|
/10/, /11/, /12/, /13/, /14/
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Continue
|
// Continue
|
||||||
addTest('c', [
|
addTest('c', [
|
||||||
|
/debug>/,
|
||||||
/break in .*:5/,
|
/break in .*:5/,
|
||||||
/3/, /4/, /5/, /6/, /7/
|
/3/, /4/, /5/, /6/, /7/
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Set breakpoint by function name
|
// Set breakpoint by function name
|
||||||
addTest('sb("setInterval()", "!(setInterval.flag++)")', [
|
addTest('sb("setInterval()", "!(setInterval.flag++)")', [
|
||||||
|
/debug>/,
|
||||||
/1/, /2/, /3/, /4/, /5/, /6/, /7/, /8/, /9/, /10/
|
/1/, /2/, /3/, /4/, /5/, /6/, /7/, /8/, /9/, /10/
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Continue
|
// Continue
|
||||||
addTest('c', [
|
addTest('c', [
|
||||||
|
/debug>/,
|
||||||
/break in node.js:\d+/,
|
/break in node.js:\d+/,
|
||||||
/\d/, /\d/, /\d/, /\d/, /\d/
|
/\d/, /\d/, /\d/, /\d/, /\d/
|
||||||
]);
|
]);
|
||||||
|
|
||||||
addTest('c', [
|
// Repeat last command
|
||||||
|
addTest('', [
|
||||||
|
/debug>/,
|
||||||
/break in .*breakpoints.js:\d+/,
|
/break in .*breakpoints.js:\d+/,
|
||||||
/\d/, /\d/, /\d/, /\d/, /\d/
|
/\d/, /\d/, /\d/, /\d/, /\d/
|
||||||
]);
|
]);
|
||||||
|
|
||||||
addTest('repl', [
|
addTest('repl', [
|
||||||
|
/debug>/,
|
||||||
/Press Ctrl \+ C to leave debug repl/
|
/Press Ctrl \+ C to leave debug repl/
|
||||||
]);
|
]);
|
||||||
|
|
||||||
addTest('now', [
|
addTest('now', [
|
||||||
|
/> now/,
|
||||||
/\w* \w* \d* \d* \d*:\d*:\d* GMT[+-]\d* (\w*)/
|
/\w* \w* \d* \d* \d*:\d*:\d* GMT[+-]\d* (\w*)/
|
||||||
]);
|
]);
|
||||||
|
|
||||||
function finish() {
|
function finish() {
|
||||||
|
// Exit debugger repl
|
||||||
|
child.kill('SIGINT');
|
||||||
|
child.kill('SIGINT');
|
||||||
|
|
||||||
|
// Exit debugger
|
||||||
|
child.kill('SIGINT');
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user