2016-03-10 21:44:54 -08:00
|
|
|
'use strict';
|
2016-11-04 11:01:26 +01:00
|
|
|
require('../common');
|
2016-03-10 21:44:54 -08:00
|
|
|
const assert = require('assert');
|
|
|
|
const spawn = require('child_process').spawn;
|
|
|
|
|
2018-12-03 17:15:45 +01:00
|
|
|
// Spawn a node child process in "interactive" mode (force the repl) and eval
|
2016-03-10 21:44:54 -08:00
|
|
|
const cp = spawn(process.execPath, ['-i', '-e', 'console.log("42")']);
|
2017-01-08 13:19:00 +00:00
|
|
|
let gotToEnd = false;
|
2016-03-10 21:44:54 -08:00
|
|
|
|
|
|
|
cp.stdout.setEncoding('utf8');
|
|
|
|
|
2017-01-08 13:19:00 +00:00
|
|
|
let output = '';
|
2016-03-10 21:44:54 -08:00
|
|
|
cp.stdout.on('data', function(b) {
|
|
|
|
output += b;
|
2018-12-19 22:51:30 +08:00
|
|
|
if (output.endsWith('> 42\n')) {
|
2016-03-10 21:44:54 -08:00
|
|
|
gotToEnd = true;
|
|
|
|
cp.kill();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
process.on('exit', function() {
|
|
|
|
assert(gotToEnd);
|
|
|
|
});
|