11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_cirequire('../common'); 31cb0ef41Sopenharmony_ciconst assert = require('assert'); 41cb0ef41Sopenharmony_ciconst spawn = require('child_process').spawn; 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ci// Spawn a node child process in "interactive" mode (force the repl) and eval 71cb0ef41Sopenharmony_ciconst cp = spawn(process.execPath, ['-i', '-e', 'console.log("42")']); 81cb0ef41Sopenharmony_cilet gotToEnd = false; 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_cicp.stdout.setEncoding('utf8'); 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_cilet output = ''; 131cb0ef41Sopenharmony_cicp.stdout.on('data', function(b) { 141cb0ef41Sopenharmony_ci output += b; 151cb0ef41Sopenharmony_ci if (output.endsWith('> 42\n')) { 161cb0ef41Sopenharmony_ci gotToEnd = true; 171cb0ef41Sopenharmony_ci cp.kill(); 181cb0ef41Sopenharmony_ci } 191cb0ef41Sopenharmony_ci}); 201cb0ef41Sopenharmony_ci 211cb0ef41Sopenharmony_ciprocess.on('exit', function() { 221cb0ef41Sopenharmony_ci assert(gotToEnd); 231cb0ef41Sopenharmony_ci}); 24