summaryrefslogtreecommitdiff
path: root/test/parallel/test-cwd-enoent-repl.js
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2015-03-18 22:31:16 +0100
committerBen Noordhuis <info@bnoordhuis.nl>2015-03-19 02:11:38 +0100
commit2b2e48a4b91a4b636ae0e603968bd764697d1e57 (patch)
tree66b667c086dd66d9d763891347ab737b2cd6207a /test/parallel/test-cwd-enoent-repl.js
parent2c6f79c08cba4e7adee9de2283c7d08cf977adcb (diff)
downloadandroid-node-v8-2b2e48a4b91a4b636ae0e603968bd764697d1e57.tar.gz
android-node-v8-2b2e48a4b91a4b636ae0e603968bd764697d1e57.tar.bz2
android-node-v8-2b2e48a4b91a4b636ae0e603968bd764697d1e57.zip
lib: don't error in repl when cwd doesn't exist
The current working directory may not exist when the REPL starts up. Don't treat that as an error because it's still possible to do many useful things. This is like the previous commit but for the REPL. 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-repl.js')
-rw-r--r--test/parallel/test-cwd-enoent-repl.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/parallel/test-cwd-enoent-repl.js b/test/parallel/test-cwd-enoent-repl.js
new file mode 100644
index 0000000000..64538f80b9
--- /dev/null
+++ b/test/parallel/test-cwd-enoent-repl.js
@@ -0,0 +1,26 @@
+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, ['--interactive']);
+proc.stdout.pipe(process.stdout);
+proc.stderr.pipe(process.stderr);
+proc.stdin.write('require("path");\n');
+proc.stdin.write('process.exit(42);\n');
+
+proc.once('exit', common.mustCall(function(exitCode, signalCode) {
+ assert.equal(exitCode, 42);
+ assert.equal(signalCode, null);
+}));