2025-01-07 07:24:20 +01:00
|
|
|
'use strict';
|
|
|
|
|
2025-04-18 06:07:51 -05:00
|
|
|
const { isWindows, isIBMi, mustCall, skip } = require('../common');
|
2025-01-07 07:24:20 +01:00
|
|
|
const { throws } = require('assert');
|
|
|
|
const { isMainThread, Worker } = require('worker_threads');
|
|
|
|
|
2025-04-18 06:07:51 -05:00
|
|
|
if (isWindows || isIBMi) {
|
|
|
|
skip('process.execve is not available in Windows or IBM i');
|
2025-01-07 07:24:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (isMainThread) {
|
|
|
|
new Worker(__filename);
|
|
|
|
} else {
|
|
|
|
throws(mustCall(() => {
|
|
|
|
process.execve(
|
|
|
|
process.execPath,
|
|
|
|
[__filename, 'replaced'],
|
|
|
|
{ ...process.env, EXECVE_A: 'FIRST', EXECVE_B: 'SECOND', CWD: process.cwd() }
|
|
|
|
);
|
|
|
|
}), { name: 'TypeError', code: 'ERR_WORKER_UNSUPPORTED_OPERATION' });
|
|
|
|
}
|