diff options
author | Rich Trott <rtrott@gmail.com> | 2015-06-09 11:40:55 -0700 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2015-06-13 22:27:17 -0700 |
commit | 7c79490bfbfee3868c1524207fcd11e0149b9c73 (patch) | |
tree | 2b93b80b6921c0f81d36efcd51c2524d875c6669 /test/common.js | |
parent | 88d7904c0ba66bd2ced87f674d3f6ee098db970c (diff) | |
download | nodejs-7c79490bfbfee3868c1524207fcd11e0149b9c73.tar.gz nodejs-7c79490bfbfee3868c1524207fcd11e0149b9c73.tar.bz2 nodejs-7c79490bfbfee3868c1524207fcd11e0149b9c73.zip |
test: only refresh tmpDir for tests that need it
Expose `common.refreshTmpDir()` and only call it
for tests that use common.tmpDir or common.PIPE.
A positive side effect is the removal of a code
smell where child processes were detected by the
presence of `.send()`. Now each process can decide
for itself if it needs to refresh tmpDir.
PR-URL: https://github.com/nodejs/io.js/pull/1954
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Diffstat (limited to 'test/common.js')
-rw-r--r-- | test/common.js | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/test/common.js b/test/common.js index e88893cd1..704c64baf 100644 --- a/test/common.js +++ b/test/common.js @@ -51,19 +51,17 @@ function rmdirSync(p, originalEr) { } } -function refreshTmpDir() { - if (!process.send) { // Not a child process - try { - rimrafSync(exports.tmpDir); - } catch (e) { - } +exports.refreshTmpDir = function() { + try { + rimrafSync(exports.tmpDir); + } catch (e) { + } - try { - fs.mkdirSync(exports.tmpDir); - } catch (e) { - } + try { + fs.mkdirSync(exports.tmpDir); + } catch (e) { } -} +}; if (process.env.TEST_THREAD_ID) { // Distribute ports in parallel tests @@ -74,8 +72,6 @@ if (process.env.TEST_THREAD_ID) { } exports.tmpDir = path.join(exports.testDir, exports.tmpDirName); -refreshTmpDir(); - var opensslCli = null; var inFreeBSDJail = null; var localhostIPv4 = null; |