Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 432cb35

Browse filesBrowse files
cjihrigevanlucas
authored andcommitted
test: add common.rootDir
A few of the child process tests can be simplified by computing the OS specific root directory in common and then accessing that value. PR-URL: #7685 Reviewed-By: Roman Reiss <me@silverwind.io>
1 parent 989a2a1 commit 432cb35
Copy full SHA for 432cb35

File tree

Expand file treeCollapse file tree

4 files changed

+8
-15
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

4 files changed

+8
-15
lines changed
Open diff view settings
Collapse file

‎test/common.js‎

Copy file name to clipboardExpand all lines: test/common.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ exports.isSunOS = process.platform === 'sunos';
2727
exports.isFreeBSD = process.platform === 'freebsd';
2828

2929
exports.enoughTestMem = os.totalmem() > 0x20000000; /* 512MB */
30+
exports.rootDir = exports.isWindows ? 'c:\\' : '/';
3031

3132
function rimrafSync(p) {
3233
try {
Collapse file

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

Copy file name to clipboardExpand all lines: test/parallel/test-child-process-cwd.js
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,11 @@ function testCwd(options, forCode, forData) {
3636
}
3737

3838
// Assume these exist, and 'pwd' gives us the right directory back
39+
testCwd({cwd: common.rootDir}, 0, common.rootDir);
3940
if (common.isWindows) {
4041
testCwd({cwd: process.env.windir}, 0, process.env.windir);
41-
testCwd({cwd: 'c:\\'}, 0, 'c:\\');
4242
} else {
4343
testCwd({cwd: '/dev'}, 0, '/dev');
44-
testCwd({cwd: '/'}, 0, '/');
4544
}
4645

4746
// Assume does-not-exist doesn't exist, expect exitCode=-1 and errno=ENOENT
Collapse file

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

Copy file name to clipboardExpand all lines: test/parallel/test-child-process-spawnsync.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ assert.deepStrictEqual(ret_err.spawnargs, ['bar']);
2020

2121
{
2222
// Test the cwd option
23-
const cwd = common.isWindows ? 'c:\\' : '/';
23+
const cwd = common.rootDir;
2424
const response = common.spawnSyncPwd({cwd});
2525

2626
assert.strictEqual(response.stdout.toString().trim(), cwd);
Collapse file

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

Copy file name to clipboardExpand all lines: test/sequential/test-child-process-execsync.js
+5-12Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,13 @@ assert.strictEqual(ret, msg + '\n',
6161
'execFileSync encoding result should match');
6262

6363
// Verify that the cwd option works - GH #7824
64-
(function() {
65-
var response;
66-
var cwd;
67-
68-
if (common.isWindows) {
69-
cwd = 'c:\\';
70-
response = execSync('echo %cd%', {cwd: cwd});
71-
} else {
72-
cwd = '/';
73-
response = execSync('pwd', {cwd: cwd});
74-
}
64+
{
65+
const cwd = common.rootDir;
66+
const cmd = common.isWindows ? 'echo %cd%' : 'pwd';
67+
const response = execSync(cmd, {cwd});
7568

7669
assert.strictEqual(response.toString().trim(), cwd);
77-
})();
70+
}
7871

7972
// Verify that stderr is not accessed when stdio = 'ignore' - GH #7966
8073
(function() {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.