Skip to content

Commit a0ba416

Browse files
Trottaddaleax
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 5352cde commit a0ba416

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
@@ -367,12 +367,6 @@ const { spawn } = require('child_process');
367367
spawn(...common.pwdCommand, { stdio: ['pipe'] });
368368
```
369369

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

378372
* `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';
@@ -737,7 +735,6 @@ const common = {
737735
platformTimeout,
738736
printSkipMessage,
739737
pwdCommand,
740-
rootDir,
741738
runWithInvalidFD,
742739
skip,
743740
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

@@ -40,7 +43,7 @@ assert.deepStrictEqual(ret_err.spawnargs, ['bar']);
4043

4144
{
4245
// Test the cwd option
43-
const cwd = common.rootDir;
46+
const cwd = tmpdir.path;
4447
const response = spawnSync(...common.pwdCommand, { cwd });
4548

4649
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');
@@ -98,7 +101,7 @@ const args = [
98101
// Verify that the cwd option works.
99102
// See https://github.com/nodejs/node-v0.x-archive/issues/7824.
100103
{
101-
const cwd = common.rootDir;
104+
const cwd = tmpdir.path;
102105
const cmd = common.isWindows ? 'echo %cd%' : 'pwd';
103106
const response = execSync(cmd, { cwd });
104107

0 commit comments

Comments
 (0)