Skip to content

test: add common.rootDir #7685

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ exports.isSunOS = process.platform === 'sunos';
exports.isFreeBSD = process.platform === 'freebsd';

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

function rimrafSync(p) {
try {
Expand Down
3 changes: 1 addition & 2 deletions test/parallel/test-child-process-cwd.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,11 @@ function testCwd(options, forCode, forData) {
}

// Assume these exist, and 'pwd' gives us the right directory back
testCwd({cwd: common.rootDir}, 0, common.rootDir);
if (common.isWindows) {
testCwd({cwd: process.env.windir}, 0, process.env.windir);
testCwd({cwd: 'c:\\'}, 0, 'c:\\');
} else {
testCwd({cwd: '/dev'}, 0, '/dev');
testCwd({cwd: '/'}, 0, '/');
}

// Assume does-not-exist doesn't exist, expect exitCode=-1 and errno=ENOENT
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-child-process-spawnsync.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ assert.deepStrictEqual(ret_err.spawnargs, ['bar']);

{
// Test the cwd option
const cwd = common.isWindows ? 'c:\\' : '/';
const cwd = common.rootDir;
const response = common.spawnSyncPwd({cwd});

assert.strictEqual(response.stdout.toString().trim(), cwd);
Expand Down
17 changes: 5 additions & 12 deletions test/sequential/test-child-process-execsync.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,13 @@ assert.strictEqual(ret, msg + '\n',
'execFileSync encoding result should match');

// Verify that the cwd option works - GH #7824
(function() {
var response;
var cwd;

if (common.isWindows) {
cwd = 'c:\\';
response = execSync('echo %cd%', {cwd: cwd});
} else {
cwd = '/';
response = execSync('pwd', {cwd: cwd});
}
{
const cwd = common.rootDir;
const cmd = common.isWindows ? 'echo %cd%' : 'pwd';
const response = execSync(cmd, {cwd});

assert.strictEqual(response.toString().trim(), cwd);
})();
}

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