11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ci// This tests that process.argv is the same in the preloaded module 41cb0ef41Sopenharmony_ci// and the user module. 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_cirequire('../common'); 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ciconst tmpdir = require('../common/tmpdir'); 91cb0ef41Sopenharmony_ciconst assert = require('assert'); 101cb0ef41Sopenharmony_ciconst { join } = require('path'); 111cb0ef41Sopenharmony_ciconst { spawnSync } = require('child_process'); 121cb0ef41Sopenharmony_ciconst fs = require('fs'); 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_citmpdir.refresh(); 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_cifs.writeFileSync( 171cb0ef41Sopenharmony_ci join(tmpdir.path, 'preload.js'), 181cb0ef41Sopenharmony_ci 'console.log(JSON.stringify(process.argv));', 191cb0ef41Sopenharmony_ci 'utf-8'); 201cb0ef41Sopenharmony_ci 211cb0ef41Sopenharmony_cifs.writeFileSync( 221cb0ef41Sopenharmony_ci join(tmpdir.path, 'main.js'), 231cb0ef41Sopenharmony_ci 'console.log(JSON.stringify(process.argv));', 241cb0ef41Sopenharmony_ci 'utf-8'); 251cb0ef41Sopenharmony_ci 261cb0ef41Sopenharmony_ciconst child = spawnSync(process.execPath, ['-r', './preload.js', 'main.js'], 271cb0ef41Sopenharmony_ci { cwd: tmpdir.path }); 281cb0ef41Sopenharmony_ci 291cb0ef41Sopenharmony_ciif (child.status !== 0) { 301cb0ef41Sopenharmony_ci console.log(child.stderr.toString()); 311cb0ef41Sopenharmony_ci assert.strictEqual(child.status, 0); 321cb0ef41Sopenharmony_ci} 331cb0ef41Sopenharmony_ci 341cb0ef41Sopenharmony_ciconst lines = child.stdout.toString().trim().split('\n'); 351cb0ef41Sopenharmony_ciassert.deepStrictEqual(JSON.parse(lines[0]), JSON.parse(lines[1])); 36