11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ciconst common = require('../common');
31cb0ef41Sopenharmony_ciconst fixtures = require('../common/fixtures');
41cb0ef41Sopenharmony_ciconst assert = require('assert');
51cb0ef41Sopenharmony_ciconst child_process = require('child_process');
61cb0ef41Sopenharmony_ciconst path = require('path');
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_cicommon.allowGlobals(global.require);
91cb0ef41Sopenharmony_cicommon.allowGlobals(global.embedVars);
101cb0ef41Sopenharmony_cilet binary = `out/${common.buildType}/embedtest`;
111cb0ef41Sopenharmony_ciif (common.isWindows) {
121cb0ef41Sopenharmony_ci  binary += '.exe';
131cb0ef41Sopenharmony_ci}
141cb0ef41Sopenharmony_cibinary = path.resolve(__dirname, '..', '..', binary);
151cb0ef41Sopenharmony_ci
161cb0ef41Sopenharmony_ciassert.strictEqual(
171cb0ef41Sopenharmony_ci  child_process.spawnSync(binary, ['console.log(42)'])
181cb0ef41Sopenharmony_ci    .stdout.toString().trim(),
191cb0ef41Sopenharmony_ci  '42');
201cb0ef41Sopenharmony_ci
211cb0ef41Sopenharmony_ciassert.strictEqual(
221cb0ef41Sopenharmony_ci  child_process.spawnSync(binary, ['console.log(embedVars.nön_ascıı)'])
231cb0ef41Sopenharmony_ci    .stdout.toString().trim(),
241cb0ef41Sopenharmony_ci  '�️‍�');
251cb0ef41Sopenharmony_ci
261cb0ef41Sopenharmony_ciassert.strictEqual(
271cb0ef41Sopenharmony_ci  child_process.spawnSync(binary, ['console.log(42)'])
281cb0ef41Sopenharmony_ci    .stdout.toString().trim(),
291cb0ef41Sopenharmony_ci  '42');
301cb0ef41Sopenharmony_ci
311cb0ef41Sopenharmony_ciassert.strictEqual(
321cb0ef41Sopenharmony_ci  child_process.spawnSync(binary, ['throw new Error()']).status,
331cb0ef41Sopenharmony_ci  1);
341cb0ef41Sopenharmony_ci
351cb0ef41Sopenharmony_ciassert.strictEqual(
361cb0ef41Sopenharmony_ci  child_process.spawnSync(binary, ['process.exitCode = 8']).status,
371cb0ef41Sopenharmony_ci  8);
381cb0ef41Sopenharmony_ci
391cb0ef41Sopenharmony_ci
401cb0ef41Sopenharmony_ciconst fixturePath = JSON.stringify(fixtures.path('exit.js'));
411cb0ef41Sopenharmony_ciassert.strictEqual(
421cb0ef41Sopenharmony_ci  child_process.spawnSync(binary, [`require(${fixturePath})`, 92]).status,
431cb0ef41Sopenharmony_ci  92);
44