Skip to content

Commit

Permalink
test: remove common.rootDir
Browse files Browse the repository at this point in the history
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 <luigipinca@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
  • Loading branch information
Trott authored and BethGriggs committed Aug 20, 2020
1 parent 1c324d5 commit c458e84
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 14 deletions.
6 changes: 0 additions & 6 deletions test/common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -368,12 +368,6 @@ const { spawn } = require('child_process');
spawn(...common.pwdCommand, { stdio: ['pipe'] });
```

### `rootDir`

* [&lt;string>][]

Path to the 'root' directory. either `/` or `c:\\` (windows)

### `runWithInvalidFD(func)`

* `func` [&lt;Function>][]
Expand Down
3 changes: 0 additions & 3 deletions test/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -723,7 +721,6 @@ const common = {
platformTimeout,
printSkipMessage,
pwdCommand,
rootDir,
runWithInvalidFD,
skip,
skipIf32Bits,
Expand Down
2 changes: 0 additions & 2 deletions test/common/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const {
isOSX,
enoughTestMem,
enoughTestCpu,
rootDir,
buildType,
localIPv6Hosts,
opensslCli,
Expand Down Expand Up @@ -66,7 +65,6 @@ export {
isOSX,
enoughTestMem,
enoughTestCpu,
rootDir,
buildType,
localIPv6Hosts,
opensslCli,
Expand Down
5 changes: 4 additions & 1 deletion test/parallel/test-child-process-cwd.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -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);

Expand Down
5 changes: 4 additions & 1 deletion test/parallel/test-child-process-spawnsync.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion test/sequential/test-child-process-execsync.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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 });

Expand Down

0 comments on commit c458e84

Please sign in to comment.