2016-04-06 02:17:33 +02:00
|
|
|
'use strict';
|
2016-07-18 22:33:42 +02:00
|
|
|
const common = require('../common');
|
2016-04-06 02:17:33 +02:00
|
|
|
const path = require('path');
|
|
|
|
const spawn = require('child_process').spawn;
|
|
|
|
const assert = require('assert');
|
|
|
|
const fixture = path.join(
|
|
|
|
common.fixturesDir,
|
|
|
|
'debugger-repeat-last.js'
|
|
|
|
);
|
|
|
|
|
|
|
|
const args = [
|
|
|
|
'debug',
|
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');
|
|
|
|
|
|
|
|
var stdout = '';
|
|
|
|
|
|
|
|
var sentCommand = false;
|
|
|
|
var sentEmpty = false;
|
|
|
|
var sentExit = false;
|
|
|
|
|
|
|
|
proc.stdout.on('data', (data) => {
|
|
|
|
stdout += data;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
if (!sentEmpty && stdout.includes('> 3')) {
|
2016-12-21 06:54:04 +01:00
|
|
|
setImmediate(() => { proc.stdin.write('\n'); });
|
2016-04-06 02:17:33 +02:00
|
|
|
return sentEmpty = true;
|
|
|
|
}
|
|
|
|
if (!sentExit && sentCommand && sentEmpty) {
|
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);
|
|
|
|
});
|