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 committed Aug 16, 2020
1 parent 0e1fd8d commit 42a3a7f
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
Expand Up @@ -369,12 +369,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
Expand Up @@ -115,8 +115,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 @@ -726,7 +724,6 @@ const common = {
platformTimeout,
printSkipMessage,
pwdCommand,
rootDir,
runWithInvalidFD,
skip,
skipIf32Bits,
Expand Down
2 changes: 0 additions & 2 deletions test/common/index.mjs
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
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
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
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 42a3a7f

Please sign in to comment.