Files
node/test/parallel/test-process-execve-abort.js
T
Paolo Insogna 2ce79787de process: add execve
PR-URL: https://github.com/nodejs/node/pull/56496
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Bryan English <bryan@bryanenglish.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2025-04-17 10:51:51 -03:00

27 lines
852 B
JavaScript

'use strict';
const { skip, isWindows } = require('../common');
const { ok } = require('assert');
const { spawnSync } = require('child_process');
const { isMainThread } = require('worker_threads');
if (!isMainThread) {
skip('process.execve is not available in Workers');
} else if (isWindows) {
skip('process.execve is not available in Windows');
}
if (process.argv[2] === 'child') {
process.execve(
process.execPath + '_non_existing',
[__filename, 'replaced'],
{ ...process.env, EXECVE_A: 'FIRST', EXECVE_B: 'SECOND', CWD: process.cwd() }
);
} else {
const child = spawnSync(`${process.execPath}`, [`${__filename}`, 'child']);
const stderr = child.stderr.toString();
ok(stderr.includes('process.execve failed with error code ENOENT'), stderr);
ok(stderr.includes('execve (node:internal/process/per_thread'), stderr);
}