aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGrigorii K. Shartsev <me@shgk.me>2019-05-26 17:10:38 +0300
committerСковорода Никита Андреевич <chalkerx@gmail.com>2019-05-27 17:12:57 +0300
commite3555e9c2b2877d1214474647a6bae6207046bfb (patch)
tree3639fd9f70a9c954257815944b7fc1f325f6894e /test
parent55de6ff38dfc639d82a1acbd9016fd4ebe67240f (diff)
downloadandroid-node-v8-e3555e9c2b2877d1214474647a6bae6207046bfb.tar.gz
android-node-v8-e3555e9c2b2877d1214474647a6bae6207046bfb.tar.bz2
android-node-v8-e3555e9c2b2877d1214474647a6bae6207046bfb.zip
test: add a test case for the path.posix.resolve
In posix path.resolve should handle relative paths to be safe even if process.cwd fails. At lib/path.js#999: return resolvedPath.length > 0 ? resolvedPath : '.'; Else branch wasn't covered. Add a test case to cover this. PR-URL: https://github.com/nodejs/node/pull/27905 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-path-resolve.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/parallel/test-path-resolve.js b/test/parallel/test-path-resolve.js
index e9e6d83ff5..ed3c7c4c5a 100644
--- a/test/parallel/test-path-resolve.js
+++ b/test/parallel/test-path-resolve.js
@@ -69,3 +69,12 @@ if (common.isWindows) {
const resolvedPath = spawnResult.stdout.toString().trim();
assert.strictEqual(resolvedPath.toLowerCase(), process.cwd().toLowerCase());
}
+
+if (!common.isWindows) {
+ // Test handling relative paths to be safe when process.cwd() fails.
+ process.cwd = () => '';
+ assert.strictEqual(process.cwd(), '');
+ const resolved = path.resolve();
+ const expected = '.';
+ assert.strictEqual(resolved, expected);
+}