summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorcjihrig <cjihrig@gmail.com>2016-07-12 12:17:28 -0400
committercjihrig <cjihrig@gmail.com>2016-07-14 10:06:13 -0400
commite9bb3329eafce174f234fe71539e2d8b6e42ec7b (patch)
tree5e2777af6d21c7451321d7db6e73e2f41495c5e5 /test
parenta58b48bc3bcf43f7090d4cc914606af68fe55815 (diff)
downloadandroid-node-v8-e9bb3329eafce174f234fe71539e2d8b6e42ec7b.tar.gz
android-node-v8-e9bb3329eafce174f234fe71539e2d8b6e42ec7b.tar.bz2
android-node-v8-e9bb3329eafce174f234fe71539e2d8b6e42ec7b.zip
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: https://github.com/nodejs/node/pull/7685 Reviewed-By: Roman Reiss <me@silverwind.io>
Diffstat (limited to 'test')
-rw-r--r--test/common.js1
-rw-r--r--test/parallel/test-child-process-cwd.js3
-rw-r--r--test/parallel/test-child-process-spawnsync.js2
-rw-r--r--test/sequential/test-child-process-execsync.js17
4 files changed, 8 insertions, 15 deletions
diff --git a/test/common.js b/test/common.js
index 5aefdc3bce..f9d80ff149 100644
--- a/test/common.js
+++ b/test/common.js
@@ -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 {
diff --git a/test/parallel/test-child-process-cwd.js b/test/parallel/test-child-process-cwd.js
index f13da684fb..108538629e 100644
--- a/test/parallel/test-child-process-cwd.js
+++ b/test/parallel/test-child-process-cwd.js
@@ -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
diff --git a/test/parallel/test-child-process-spawnsync.js b/test/parallel/test-child-process-spawnsync.js
index d45cc1e0dc..77d205f79a 100644
--- a/test/parallel/test-child-process-spawnsync.js
+++ b/test/parallel/test-child-process-spawnsync.js
@@ -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);
diff --git a/test/sequential/test-child-process-execsync.js b/test/sequential/test-child-process-execsync.js
index fcb923a38f..2fad4ba8c2 100644
--- a/test/sequential/test-child-process-execsync.js
+++ b/test/sequential/test-child-process-execsync.js
@@ -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() {