2016-04-06 02:17:33 +02:00
|
|
|
'use strict';
|
2016-07-18 22:33:42 +02:00
|
|
|
const common = require('../common');
|
2017-04-24 16:13:21 +02:00
|
|
|
common.skipIfInspectorDisabled();
|
2017-08-09 19:29:40 +02:00
|
|
|
const path = require('../common/fixtures').path;
|
2016-04-06 02:17:33 +02:00
|
|
|
const spawn = require('child_process').spawn;
|
|
|
|
const assert = require('assert');
|
2017-08-09 19:29:40 +02:00
|
|
|
const fixture = path('debugger-repeat-last.js');
|
2016-04-06 02:17:33 +02:00
|
|
|
|
|
|
|
const args = [
|
2017-04-24 16:13:21 +02:00
|
|
|
'inspect',
|
2016-04-15 15:38:04 +02:00
|
|
|
`--port=${common.PORT}`,
|
2016-04-06 02:17:33 +02:00
|
|
|
fixture
|
|
|
|
];
|
|
|
|
|
|
|
|
const proc = spawn(process.execPath, args, { stdio: 'pipe' });
|
|
|
|
proc.stdout.setEncoding('utf8');
|
|
|
|
|
2017-01-08 14:19:00 +01:00
|
|
|
let stdout = '';
|
2016-04-06 02:17:33 +02:00
|
|
|
|
2017-01-08 14:19:00 +01:00
|
|
|
let sentCommand = false;
|
|
|
|
let sentExit = false;
|
2016-04-06 02:17:33 +02:00
|
|
|
|
|
|
|
proc.stdout.on('data', (data) => {
|
|
|
|
stdout += data;
|
2017-03-14 22:20:38 +01:00
|
|
|
|
|
|
|
// Send 'n' as the first step.
|
|
|
|
if (!sentCommand && stdout.includes('> 1 ')) {
|
2016-12-21 06:54:04 +01:00
|
|
|
setImmediate(() => { proc.stdin.write('n\n'); });
|
2016-04-06 02:17:33 +02:00
|
|
|
return sentCommand = true;
|
|
|
|
}
|
2017-03-14 22:20:38 +01:00
|
|
|
// Send empty (repeat last command) until we reach line 5.
|
|
|
|
if (sentCommand && !stdout.includes('> 5')) {
|
2016-12-21 06:54:04 +01:00
|
|
|
setImmediate(() => { proc.stdin.write('\n'); });
|
2017-03-14 22:20:38 +01:00
|
|
|
return true;
|
2016-04-06 02:17:33 +02:00
|
|
|
}
|
2017-03-14 22:20:38 +01:00
|
|
|
if (!sentExit && stdout.includes('> 5')) {
|
2016-12-21 06:54:04 +01:00
|
|
|
setTimeout(() => { proc.stdin.write('\n\n\n.exit\n\n\n'); }, 1);
|
2016-04-06 02:17:33 +02:00
|
|
|
return sentExit = true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
process.on('exit', (exitCode) => {
|
|
|
|
assert.strictEqual(exitCode, 0);
|
|
|
|
console.log(stdout);
|
|
|
|
});
|