forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-process-execve.js
More file actions
27 lines (23 loc) · 905 Bytes
/
Copy pathtest-process-execve.js
File metadata and controls
27 lines (23 loc) · 905 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
'use strict';
const { isWindows, isIBMi, skip } = require('../common');
const { deepStrictEqual, fail, strictEqual } = require('assert');
const { isMainThread } = require('worker_threads');
if (!isMainThread) {
skip('process.execve is not available in Workers');
} else if (isWindows || isIBMi) {
skip('process.execve is not available in Windows or IBM i');
}
if (process.argv[2] === 'replaced') {
deepStrictEqual(process.argv, [process.execPath, __filename, 'replaced']);
strictEqual(process.env.CWD, process.cwd());
strictEqual(process.env.EXECVE_A, 'FIRST');
strictEqual(process.env.EXECVE_B, 'SECOND');
} else {
process.execve(
process.execPath,
[process.execPath, __filename, 'replaced'],
{ ...process.env, EXECVE_A: 'FIRST', EXECVE_B: 'SECOND', CWD: process.cwd() }
);
// If process.execve succeed, this should never be executed.
fail('process.execve failed');
}