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>
This commit is contained in:
parent
55de6ff38d
commit
e3555e9c2b
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user