summaryrefslogtreecommitdiff
path: root/test/parallel/test-cwd-enoent.js
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2015-03-18 22:11:14 +0100
committerBen Noordhuis <info@bnoordhuis.nl>2015-03-19 02:10:36 +0100
commit2c6f79c08cba4e7adee9de2283c7d08cf977adcb (patch)
treef71de96866f7bfd0f7c3a27cdf557442bde922a1 /test/parallel/test-cwd-enoent.js
parentc15e81afdd5413f94df23eb82b6fc65875cb07fb (diff)
downloadandroid-node-v8-2c6f79c08cba4e7adee9de2283c7d08cf977adcb.tar.gz
android-node-v8-2c6f79c08cba4e7adee9de2283c7d08cf977adcb.tar.bz2
android-node-v8-2c6f79c08cba4e7adee9de2283c7d08cf977adcb.zip
src: don't error at startup when cwd doesn't exist
The current working directory may not exist when iojs starts up. Don't treat that as an error because it's still possible to do many useful things, like evaluating a command line script or starting a REPL. This commit also fixes an age-old Windows bug where process.argv[0] was not properly expanded, that's why the parallel/test-process-argv-0 test gets an update as well. Fixes: https://github.com/iojs/io.js/issues/1184 PR-URL: https://github.com/iojs/io.js/pull/1194 Reviewed-By: Johan Bergström <bugs@bergstroem.nu> Reviewed-By: Rod Vagg <rod@vagg.org>
Diffstat (limited to 'test/parallel/test-cwd-enoent.js')
-rw-r--r--test/parallel/test-cwd-enoent.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/parallel/test-cwd-enoent.js b/test/parallel/test-cwd-enoent.js
new file mode 100644
index 0000000000..6e7b02c85d
--- /dev/null
+++ b/test/parallel/test-cwd-enoent.js
@@ -0,0 +1,24 @@
+var common = require('../common');
+var assert = require('assert');
+var fs = require('fs');
+var spawn = require('child_process').spawn;
+
+// Fails with EINVAL on SmartOS, EBUSY on Windows.
+if (process.platform === 'sunos' || process.platform === 'win32') {
+ console.log('1..0 # Skipped: cannot rmdir current working directory');
+ return;
+}
+
+var dirname = common.tmpDir + '/cwd-does-not-exist-' + process.pid;
+fs.mkdirSync(dirname);
+process.chdir(dirname);
+fs.rmdirSync(dirname);
+
+var proc = spawn(process.execPath, ['-e', '0']);
+proc.stdout.pipe(process.stdout);
+proc.stderr.pipe(process.stderr);
+
+proc.once('exit', common.mustCall(function(exitCode, signalCode) {
+ assert.equal(exitCode, 0);
+ assert.equal(signalCode, null);
+}));