11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ciconst assert = require('assert'); 41cb0ef41Sopenharmony_ciconst cp = require('child_process'); 51cb0ef41Sopenharmony_ciconst stdoutData = 'foo'; 61cb0ef41Sopenharmony_ciconst stderrData = 'bar'; 71cb0ef41Sopenharmony_ciconst expectedStdout = `${stdoutData}\n`; 81cb0ef41Sopenharmony_ciconst expectedStderr = `${stderrData}\n`; 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ciif (process.argv[2] === 'child') { 111cb0ef41Sopenharmony_ci // The following console calls are part of the test. 121cb0ef41Sopenharmony_ci console.log(stdoutData); 131cb0ef41Sopenharmony_ci console.error(stderrData); 141cb0ef41Sopenharmony_ci} else { 151cb0ef41Sopenharmony_ci const cmd = `"${process.execPath}" "${__filename}" child`; 161cb0ef41Sopenharmony_ci const child = cp.exec(cmd, common.mustSucceed((stdout, stderr) => { 171cb0ef41Sopenharmony_ci assert.strictEqual(stdout, expectedStdout); 181cb0ef41Sopenharmony_ci assert.strictEqual(stderr, expectedStderr); 191cb0ef41Sopenharmony_ci })); 201cb0ef41Sopenharmony_ci child.stdout.setEncoding('utf-8'); 211cb0ef41Sopenharmony_ci child.stderr.setEncoding('utf-8'); 221cb0ef41Sopenharmony_ci} 23