From c458e8406ef0b83883f1c3e9b14dcb205763ccf1 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Thu, 13 Aug 2020 21:35:35 -0700 Subject: [PATCH] test: remove common.rootDir The three tests that use common.rootDir do not need the root dir. They just need an arbitrary directory that will exist. Use tmpdir.path instead. PR-URL: https://github.com/nodejs/node/pull/34772 Reviewed-By: Luigi Pinca Reviewed-By: Richard Lau --- test/common/README.md | 6 ------ test/common/index.js | 3 --- test/common/index.mjs | 2 -- test/parallel/test-child-process-cwd.js | 5 ++++- test/parallel/test-child-process-spawnsync.js | 5 ++++- test/sequential/test-child-process-execsync.js | 5 ++++- 6 files changed, 12 insertions(+), 14 deletions(-) diff --git a/test/common/README.md b/test/common/README.md index b27083e5759c3b..b6b3089b7b4bbe 100644 --- a/test/common/README.md +++ b/test/common/README.md @@ -368,12 +368,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 00341e320c5843..6ba70b66209a44 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -114,8 +114,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'; @@ -723,7 +721,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 });