1'use strict'; 2require('../common'); 3const assert = require('assert'); 4const spawn = require('child_process').spawn; 5 6// Spawn a node child process in "interactive" mode (force the repl) and eval 7const cp = spawn(process.execPath, ['-i', '-e', 'console.log("42")']); 8let gotToEnd = false; 9 10cp.stdout.setEncoding('utf8'); 11 12let output = ''; 13cp.stdout.on('data', function(b) { 14 output += b; 15 if (output.endsWith('> 42\n')) { 16 gotToEnd = true; 17 cp.kill(); 18 } 19}); 20 21process.on('exit', function() { 22 assert(gotToEnd); 23}); 24