diff --git a/test/common/README.md b/test/common/README.md index 64f19269a01d03..1092cc1bbf52f4 100644 --- a/test/common/README.md +++ b/test/common/README.md @@ -369,12 +369,6 @@ const { spawn } = require('child_process'); spawn(...common.pwdCommand, { stdio: ['pipe'] }); ``` -### `rootDir` - -* [<string>][] - -Path to the 'root' directory. either `/` or `c:\\` (windows) - ### `runWithInvalidFD(func)` * `func` [<Function>][] diff --git a/test/common/index.js b/test/common/index.js index 6d0f31e0993850..4c0c0f86d9820e 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -115,8 +115,6 @@ const isOSX = process.platform === 'darwin'; const isDumbTerminal = process.env.TERM === 'dumb'; -const rootDir = isWindows ? 'c:\\' : '/'; - const buildType = process.config.target_defaults ? process.config.target_defaults.default_configuration : 'Release'; @@ -726,7 +724,6 @@ const common = { platformTimeout, printSkipMessage, pwdCommand, - rootDir, runWithInvalidFD, skip, skipIf32Bits, diff --git a/test/common/index.mjs b/test/common/index.mjs index fe5ed9872948b7..c0bbb9d74e1cda 100644 --- a/test/common/index.mjs +++ b/test/common/index.mjs @@ -19,7 +19,6 @@ const { isOSX, enoughTestMem, enoughTestCpu, - rootDir, buildType, localIPv6Hosts, opensslCli, @@ -66,7 +65,6 @@ export { isOSX, enoughTestMem, enoughTestCpu, - rootDir, buildType, localIPv6Hosts, opensslCli, diff --git a/test/parallel/test-child-process-cwd.js b/test/parallel/test-child-process-cwd.js index f2e0a29afb4a6d..af71edd8af3e35 100644 --- a/test/parallel/test-child-process-cwd.js +++ b/test/parallel/test-child-process-cwd.js @@ -21,6 +21,9 @@ 'use strict'; const common = require('../common'); +const tmpdir = require('../common/tmpdir'); +tmpdir.refresh(); + const assert = require('assert'); const { spawn } = require('child_process'); @@ -63,7 +66,7 @@ function testCwd(options, expectCode = 0, expectData) { } // Assume these exist, and 'pwd' gives us the right directory back -testCwd({ cwd: common.rootDir }, 0, common.rootDir); +testCwd({ cwd: tmpdir.path }, 0, tmpdir.path); const shouldExistDir = common.isWindows ? process.env.windir : '/dev'; testCwd({ cwd: shouldExistDir }, 0, shouldExistDir); diff --git a/test/parallel/test-child-process-spawnsync.js b/test/parallel/test-child-process-spawnsync.js index ae87d5245c8c71..c464dbefa68e5e 100644 --- a/test/parallel/test-child-process-spawnsync.js +++ b/test/parallel/test-child-process-spawnsync.js @@ -21,6 +21,9 @@ 'use strict'; const common = require('../common'); +const tmpdir = require('../common/tmpdir'); +tmpdir.refresh(); + const assert = require('assert'); const { spawnSync } = require('child_process'); const { getSystemErrorName } = require('util'); @@ -41,7 +44,7 @@ assert.deepStrictEqual(ret_err.spawnargs, ['bar']); { // Test the cwd option - const cwd = common.rootDir; + const cwd = tmpdir.path; const response = spawnSync(...common.pwdCommand, { cwd }); assert.strictEqual(response.stdout.toString().trim(), cwd); diff --git a/test/sequential/test-child-process-execsync.js b/test/sequential/test-child-process-execsync.js index 171ccacab65bcc..5dbf5c2f9aa915 100644 --- a/test/sequential/test-child-process-execsync.js +++ b/test/sequential/test-child-process-execsync.js @@ -21,6 +21,9 @@ 'use strict'; const common = require('../common'); +const tmpdir = require('../common/tmpdir'); +tmpdir.refresh(); + const assert = require('assert'); const { execFileSync, execSync, spawnSync } = require('child_process'); @@ -99,7 +102,7 @@ const args = [ // Verify that the cwd option works. // See https://github.com/nodejs/node-v0.x-archive/issues/7824. { - const cwd = common.rootDir; + const cwd = tmpdir.path; const cmd = common.isWindows ? 'echo %cd%' : 'pwd'; const response = execSync(cmd, { cwd });