Skip to content

Commit e38e512

Browse files
TrottMylesBorins
authored andcommitted
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: #34772 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Richard Lau <[email protected]>
1 parent b202ba8 commit e38e512

File tree

6 files changed

+12
-14
lines changed

6 files changed

+12
-14
lines changed

test/common/README.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -368,12 +368,6 @@ const { spawn } = require('child_process');
368368
spawn(...common.pwdCommand, { stdio: ['pipe'] });
369369
```
370370

371-
### `rootDir`
372-
373-
* [&lt;string>][]
374-
375-
Path to the 'root' directory. either `/` or `c:\\` (windows)
376-
377371
### `runWithInvalidFD(func)`
378372

379373
* `func` [&lt;Function>][]

test/common/index.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,6 @@ const isOSX = process.platform === 'darwin';
114114

115115
const isDumbTerminal = process.env.TERM === 'dumb';
116116

117-
const rootDir = isWindows ? 'c:\\' : '/';
118-
119117
const buildType = process.config.target_defaults ?
120118
process.config.target_defaults.default_configuration :
121119
'Release';
@@ -723,7 +721,6 @@ const common = {
723721
platformTimeout,
724722
printSkipMessage,
725723
pwdCommand,
726-
rootDir,
727724
runWithInvalidFD,
728725
skip,
729726
skipIf32Bits,

test/common/index.mjs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ const {
1919
isOSX,
2020
enoughTestMem,
2121
enoughTestCpu,
22-
rootDir,
2322
buildType,
2423
localIPv6Hosts,
2524
opensslCli,
@@ -66,7 +65,6 @@ export {
6665
isOSX,
6766
enoughTestMem,
6867
enoughTestCpu,
69-
rootDir,
7068
buildType,
7169
localIPv6Hosts,
7270
opensslCli,

test/parallel/test-child-process-cwd.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121

2222
'use strict';
2323
const common = require('../common');
24+
const tmpdir = require('../common/tmpdir');
25+
tmpdir.refresh();
26+
2427
const assert = require('assert');
2528
const { spawn } = require('child_process');
2629

@@ -63,7 +66,7 @@ function testCwd(options, expectCode = 0, expectData) {
6366
}
6467

6568
// Assume these exist, and 'pwd' gives us the right directory back
66-
testCwd({ cwd: common.rootDir }, 0, common.rootDir);
69+
testCwd({ cwd: tmpdir.path }, 0, tmpdir.path);
6770
const shouldExistDir = common.isWindows ? process.env.windir : '/dev';
6871
testCwd({ cwd: shouldExistDir }, 0, shouldExistDir);
6972

test/parallel/test-child-process-spawnsync.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121

2222
'use strict';
2323
const common = require('../common');
24+
const tmpdir = require('../common/tmpdir');
25+
tmpdir.refresh();
26+
2427
const assert = require('assert');
2528
const { spawnSync } = require('child_process');
2629
const { getSystemErrorName } = require('util');
@@ -41,7 +44,7 @@ assert.deepStrictEqual(ret_err.spawnargs, ['bar']);
4144

4245
{
4346
// Test the cwd option
44-
const cwd = common.rootDir;
47+
const cwd = tmpdir.path;
4548
const response = spawnSync(...common.pwdCommand, { cwd });
4649

4750
assert.strictEqual(response.stdout.toString().trim(), cwd);

test/sequential/test-child-process-execsync.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121

2222
'use strict';
2323
const common = require('../common');
24+
const tmpdir = require('../common/tmpdir');
25+
tmpdir.refresh();
26+
2427
const assert = require('assert');
2528

2629
const { execFileSync, execSync, spawnSync } = require('child_process');
@@ -99,7 +102,7 @@ const args = [
99102
// Verify that the cwd option works.
100103
// See https://github.com/nodejs/node-v0.x-archive/issues/7824.
101104
{
102-
const cwd = common.rootDir;
105+
const cwd = tmpdir.path;
103106
const cmd = common.isWindows ? 'echo %cd%' : 'pwd';
104107
const response = execSync(cmd, { cwd });
105108

0 commit comments

Comments
 (0)