Skip to content

Commit c458e84

Browse files
TrottBethGriggs
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 1c324d5 commit c458e84

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
constisDumbTerminal=process.env.TERM==='dumb';
116116

117-
constrootDir=isWindows ? 'c:\\' : '/';
118-
119117
constbuildType=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
constcommon=require('../common');
24+
consttmpdir=require('../common/tmpdir');
25+
tmpdir.refresh();
26+
2427
constassert=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
constshouldExistDir=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
constcommon=require('../common');
24+
consttmpdir=require('../common/tmpdir');
25+
tmpdir.refresh();
26+
2427
constassert=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-
constcwd=common.rootDir;
47+
constcwd=tmpdir.path;
4548
constresponse=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
constcommon=require('../common');
24+
consttmpdir=require('../common/tmpdir');
25+
tmpdir.refresh();
26+
2427
constassert=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-
constcwd=common.rootDir;
105+
constcwd=tmpdir.path;
103106
constcmd=common.isWindows ? 'echo %cd%' : 'pwd';
104107
constresponse=execSync(cmd,{ cwd });
105108

0 commit comments

Comments
(0)