From 46d8c93ed2350fc1742b5b0ecd1f223598778c15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Bergstr=C3=B6m?= Date: Wed, 30 Dec 2015 17:24:25 +1100 Subject: [PATCH] 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: /~https://github.com/nodejs/node/pull/4477 Reviewed-By: Rich Trott --- test/parallel/test-fs-realpath.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/test/parallel/test-fs-realpath.js b/test/parallel/test-fs-realpath.js index 26514baf48b9d1..53312c6e8d7186 100644 --- a/test/parallel/test-fs-realpath.js +++ b/test/parallel/test-fs-realpath.js @@ -236,11 +236,10 @@ function test_relative_input_cwd(callback) { return runNextTest(); } - // we need to get the relative path to the tmp dir from cwd. - // When the test runner is running it, that will be .../node/test - // but it's more common to run `./node test/.../`, so detect it here. + // we need to calculate the relative path to the tmp dir from cwd var entrydir = process.cwd(); - var entry = common.tmpDir.substr(entrydir.length + 1) + '/cycles/realpath-3a'; + var entry = path.relative(entrydir, + path.join(common.tmpDir + '/cycles/realpath-3a')); var expected = common.tmpDir + '/cycles/root.js'; [ [entry, '../cycles/realpath-3b'],