Skip to content

Commit 6efa031

Browse files
committed
test: don't use cwd for relative path
With the introduction of temporary paths in the test runner realpath tests would bail in scenarios where the temporary folder wasn't in the same directory as the source code. PR-URL: #4477 Reviewed-By: Rich Trott <[email protected]>
1 parent 842e5a1 commit 6efa031

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

test/parallel/test-fs-realpath.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,11 +232,10 @@ function test_relative_input_cwd(callback) {
232232
return runNextTest();
233233
}
234234

235-
// we need to get the relative path to the tmp dir from cwd.
236-
// When the test runner is running it, that will be .../node/test
237-
// but it's more common to run `./node test/.../`, so detect it here.
235+
// we need to calculate the relative path to the tmp dir from cwd
238236
var entrydir = process.cwd();
239-
var entry = common.tmpDir.substr(entrydir.length + 1) + '/cycles/realpath-3a';
237+
var entry = path.relative(entrydir,
238+
path.join(common.tmpDir + '/cycles/realpath-3a'));
240239
var expected = common.tmpDir + '/cycles/root.js';
241240
[
242241
[entry, '../cycles/realpath-3b'],

0 commit comments

Comments
 (0)