From c6feb4b16934905353199052ce8d1ddb2e1ee530 Mon Sep 17 00:00:00 2001 From: Gibson Fahnestock Date: Tue, 10 Jan 2017 13:43:08 +0000 Subject: [PATCH 1/2] test: use realpath for NODE_TEST_DIR in common.js If you don't specify NODE_TEST_DIR, common.tmpDir will resolve to the realpath of `node/test`. If you do specify NODE_TEST_DIR (with the environment variable or by running or by running tools/test.py --test-dir=x), common.tmpDir (which is resolved from testRoot) uses the symbolic path (doesn't resolve symlinks). This uses fs.realpathSync() to fix that. --- test/README.md | 2 +- test/common.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/README.md b/test/README.md index 4312e6fcf37e61..94f77eda5148f2 100644 --- a/test/README.md +++ b/test/README.md @@ -373,7 +373,7 @@ Synchronous version of `spawnPwd`. ### tmpDir * return [<String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) -Path to the 'tmp' directory. +The realpath of the 'tmp' directory. ### tmpDirName * return [<String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) diff --git a/test/common.js b/test/common.js index 75fcc58379be46..bb5c20241dceb2 100644 --- a/test/common.js +++ b/test/common.js @@ -12,7 +12,7 @@ const Timer = process.binding('timer_wrap').Timer; const execSync = require('child_process').execSync; const testRoot = process.env.NODE_TEST_DIR ? - path.resolve(process.env.NODE_TEST_DIR) : __dirname; + fs.realpathSync(process.env.NODE_TEST_DIR) : __dirname; exports.fixturesDir = path.join(__dirname, 'fixtures'); exports.tmpDirName = 'tmp'; From d41fc53c7e4d96589b40e55b0ee5f496197e461c Mon Sep 17 00:00:00 2001 From: Gibson Fahnestock Date: Tue, 10 Jan 2017 15:36:07 +0000 Subject: [PATCH 2/2] test: fix temp-dir option in tools/test.py If a temp-dir is specified and already exists, the NODE_TEST_DIR environment variable will never be set. This fixes that. --- tools/test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/test.py b/tools/test.py index c8edca2b991ad2..b6db2cd68e3f7e 100755 --- a/tools/test.py +++ b/tools/test.py @@ -1628,9 +1628,9 @@ def Main(): tempdir = os.environ.get('NODE_TEST_DIR') or options.temp_dir if tempdir: + os.environ['NODE_TEST_DIR'] = tempdir try: os.makedirs(tempdir) - os.environ['NODE_TEST_DIR'] = tempdir except OSError as exception: if exception.errno != errno.EEXIST: print "Could not create the temporary directory", options.temp_dir