|
23 | 23 | const process = globalThis.process; // Some tests tamper with the process globalThis. |
24 | 24 |
|
25 | 25 | const assert = require('assert'); |
26 | | -const { exec, execSync, spawn, spawnSync } = require('child_process'); |
27 | 26 | const fs = require('fs'); |
28 | 27 | const net = require('net'); |
29 | 28 | // Do not require 'os' until needed so that test-os-checked-function can |
30 | 29 | // monkey patch it. If 'os' is required here, that test will fail. |
31 | 30 | const path = require('path'); |
32 | 31 | const { inspect, getCallSites } = require('util'); |
33 | 32 | const { isMainThread } = require('worker_threads'); |
34 | | -const { isModuleNamespaceObject } = require('util/types'); |
35 | 33 |
|
36 | 34 | const tmpdir = require('./tmpdir'); |
37 | 35 | const bits = ['arm64', 'loong64', 'mips', 'mipsel', 'ppc64', 'riscv64', 's390x', 'x64'] |
@@ -104,6 +102,7 @@ if (process.argv.length === 2 && |
104 | 102 | inspect(flags), |
105 | 103 | 'Use NODE_SKIP_FLAG_CHECK to run the test with the original flags.', |
106 | 104 | ); |
| 105 | + const { spawnSync } = require('child_process'); |
107 | 106 | const args = [...flags, ...process.execArgv, ...process.argv.slice(1)]; |
108 | 107 | const options = { encoding: 'utf8', stdio: 'inherit' }; |
109 | 108 | const result = spawnSync(process.execPath, args, options); |
@@ -232,6 +231,7 @@ function childShouldThrowAndAbort() { |
232 | 231 | // continuous testing and developers' machines |
233 | 232 | escapedArgs[0] = 'ulimit -c 0 && ' + escapedArgs[0]; |
234 | 233 | } |
| 234 | + const { exec } = require('child_process'); |
235 | 235 | const child = exec(...escapedArgs); |
236 | 236 | child.on('exit', function onExit(exitCode, signal) { |
237 | 237 | const errMsg = 'Test should have aborted ' + |
@@ -474,6 +474,7 @@ function canCreateSymLink() { |
474 | 474 | 'System32', 'whoami.exe'); |
475 | 475 |
|
476 | 476 | try { |
| 477 | + const { execSync } = require('child_process'); |
477 | 478 | const output = execSync(`${whoamiPath} /priv`, { timeout: 1000 }); |
478 | 479 | return output.includes('SeCreateSymbolicLinkPrivilege'); |
479 | 480 | } catch { |
@@ -780,6 +781,7 @@ function requireNoPackageJSONAbove(dir = __dirname) { |
780 | 781 | } |
781 | 782 |
|
782 | 783 | function spawnPromisified(...args) { |
| 784 | + const { spawn } = require('child_process'); |
783 | 785 | let stderr = ''; |
784 | 786 | let stdout = ''; |
785 | 787 |
|
@@ -843,6 +845,7 @@ function escapePOSIXShell(cmdParts, ...args) { |
843 | 845 | * @param {object} expectation shape of expected namespace. |
844 | 846 | */ |
845 | 847 | function expectRequiredModule(mod, expectation, checkESModule = true) { |
| 848 | + const { isModuleNamespaceObject } = require('util/types'); |
846 | 849 | const clone = { ...mod }; |
847 | 850 | if (Object.hasOwn(mod, 'default') && checkESModule) { |
848 | 851 | assert.strictEqual(mod.__esModule, true); |
@@ -920,6 +923,7 @@ const common = { |
920 | 923 | }, |
921 | 924 |
|
922 | 925 | get inFreeBSDJail() { |
| 926 | + const { execSync } = require('child_process'); |
923 | 927 | if (inFreeBSDJail !== null) return inFreeBSDJail; |
924 | 928 |
|
925 | 929 | if (exports.isFreeBSD && |
|
0 commit comments