Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
test: move tmpdir to submodule of common
Move tmpdir functionality to its own module (common/tmpdir). PR-URL: #17856 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
- Loading branch information
Showing
with
645 additions
and 456 deletions.
- +3 −10 benchmark/http/http_server_for_chunky_client.js
- +4 −4 benchmark/module/module-loader.js
- +3 −2 test/addons/load-long-path/test.js
- +3 −2 test/addons/symlinked-module/test.js
- +2 −1 test/async-hooks/test-graph.pipeconnect.js
- +2 −1 test/async-hooks/test-pipeconnectwrap.js
- +14 −10 test/common/README.md
- +2 −64 test/common/index.js
- +67 −0 test/common/tmpdir.js
- +3 −2 test/es-module/test-esm-preserve-symlinks.js
- +3 −2 test/es-module/test-esm-symlink.js
- +3 −2 test/known_issues/test-cwd-enoent-file.js
- +4 −3 test/known_issues/test-module-deleted-extensions.js
- +4 −3 test/parallel/test-benchmark-fs.js
- +3 −2 test/parallel/test-child-process-fork-exec-path.js
- +3 −2 test/parallel/test-cli-node-options-disallowed.js
- +3 −2 test/parallel/test-cli-node-options.js
- +5 −4 test/parallel/test-cluster-cwd.js
- +2 −1 test/parallel/test-cluster-eaccess.js
- +2 −1 test/parallel/test-cluster-http-pipe.js
- +4 −2 test/parallel/test-cluster-net-listen-relative-path.js
- +4 −3 test/parallel/test-crypto-sign-verify.js
- +3 −2 test/parallel/test-cwd-enoent-preload.js
- +4 −2 test/parallel/test-cwd-enoent-repl.js
- +4 −2 test/parallel/test-cwd-enoent.js
- +3 −2 test/parallel/test-file-write-stream.js
- +5 −3 test/parallel/test-file-write-stream2.js
- +4 −2 test/parallel/test-file-write-stream3.js
- +6 −4 test/parallel/test-fs-access.js
- +7 −6 test/parallel/test-fs-append-file-sync.js
- +9 −7 test/parallel/test-fs-append-file.js
- +4 −3 test/parallel/test-fs-buffer.js
- +5 −3 test/parallel/test-fs-buffertype-writesync.js
- +5 −4 test/parallel/test-fs-chmod.js
- +3 −2 test/parallel/test-fs-copyfile.js
- +3 −2 test/parallel/test-fs-fsync.js
- +4 −3 test/parallel/test-fs-link.js
- +5 −3 test/parallel/test-fs-long-path.js
- +3 −2 test/parallel/test-fs-make-callback.js
- +3 −2 test/parallel/test-fs-mkdir-rmdir.js
- +5 −4 test/parallel/test-fs-mkdir.js
- +8 −7 test/parallel/test-fs-mkdtemp.js
- +3 −2 test/parallel/test-fs-non-number-arguments-throw.js
- +3 −2 test/parallel/test-fs-open-flags.js
- +4 −3 test/parallel/test-fs-open-numeric-flags.js
- +8 −7 test/parallel/test-fs-options-immutable.js
- +3 −2 test/parallel/test-fs-promisified.js
- +4 −3 test/parallel/test-fs-read-stream-fd.js
- +4 −3 test/parallel/test-fs-readdir-ucs2.js
- +4 −2 test/parallel/test-fs-readdir.js
- +4 −2 test/parallel/test-fs-readfile-pipe-large.js
- +5 −3 test/parallel/test-fs-readfile-unlink.js
- +4 −2 test/parallel/test-fs-readfilesync-pipe-large.js
- +5 −3 test/parallel/test-fs-realpath.js
- +5 −3 test/parallel/test-fs-sir-writes-alot.js
- +5 −4 test/parallel/test-fs-stream-double-close.js
- +5 −3 test/parallel/test-fs-symlink-dir-junction-relative.js
- +4 −2 test/parallel/test-fs-symlink-dir-junction.js
- +3 −2 test/parallel/test-fs-symlink.js
- +3 −2 test/parallel/test-fs-syncwritestream.js
- +4 −2 test/parallel/test-fs-truncate-GH-6233.js
- +3 −2 test/parallel/test-fs-truncate-fd.js
- +4 −3 test/parallel/test-fs-truncate-sync.js
- +3 −2 test/parallel/test-fs-truncate.js
- +10 −9 test/parallel/test-fs-utimes.js
- +6 −5 test/parallel/test-fs-watch-encoding.js
- +4 −2 test/parallel/test-fs-watch-recursive.js
- +3 −2 test/parallel/test-fs-watch.js
- +5 −3 test/parallel/test-fs-watchfile.js
- +8 −7 test/parallel/test-fs-write-buffer.js
- +4 −3 test/parallel/test-fs-write-file-buffer.js
- +4 −3 test/parallel/test-fs-write-file-invalid-path.js
- +5 −4 test/parallel/test-fs-write-file-sync.js
- +3 −2 test/parallel/test-fs-write-file-uint8array.js
- +6 −5 test/parallel/test-fs-write-file.js
- +4 −2 test/parallel/test-fs-write-stream-autoclose-option.js
- +5 −3 test/parallel/test-fs-write-stream-change-open.js
- +4 −3 test/parallel/test-fs-write-stream-close-without-callback.js
- +5 −4 test/parallel/test-fs-write-stream-double-close.js
- +4 −3 test/parallel/test-fs-write-stream-encoding.js
- +4 −3 test/parallel/test-fs-write-stream-end.js
- +3 −2 test/parallel/test-fs-write-stream-err.js
- +4 −2 test/parallel/test-fs-write-stream-throw-type-error.js
- +5 −3 test/parallel/test-fs-write-stream.js
- +3 −2 test/parallel/test-fs-write-string-coerce.js
- +4 −3 test/parallel/test-fs-write-sync.js
- +7 −5 test/parallel/test-fs-write.js
- +4 −2 test/parallel/test-http-agent-getname.js
- +4 −2 test/parallel/test-http-chunk-problem.js
- +2 −1 test/parallel/test-http-client-abort-keep-alive-queued-unix-socket.js
- +2 −1 test/parallel/test-http-client-abort-unix-socket.js
- +2 −1 test/parallel/test-http-client-pipe-end.js
- +2 −1 test/parallel/test-http-client-response-domain.js
- +5 −4 test/parallel/test-http-get-pipeline-problem.js
- +3 −2 test/parallel/test-http-pipe-fs.js
- +2 −1 test/parallel/test-http-unix-socket-keep-alive.js
- +2 −1 test/parallel/test-http-unix-socket.js
- +3 −2 test/parallel/test-http2-compat-serverrequest-pipe.js
- +3 −2 test/parallel/test-http2-pipe.js
- +2 −1 test/parallel/test-https-unix-socket-self-signed.js
- +3 −2 test/parallel/test-internal-fs-syncwritestream.js
- +3 −2 test/parallel/test-module-circular-symlinks.js
- +4 −3 test/parallel/test-module-loading-globalpaths.js
- +3 −2 test/parallel/test-module-symlinked-peer-modules.js
- +2 −1 test/parallel/test-net-connect-options-fd.js
- +2 −1 test/parallel/test-net-connect-options-path.js
- +2 −1 test/parallel/test-net-pingpong.js
- +3 −2 test/parallel/test-net-pipe-connect-errors.js
- +2 −1 test/parallel/test-net-server-listen-handle.js
- +2 −1 test/parallel/test-net-server-listen-path.js
- +4 −3 test/parallel/test-npm-install.js
- +2 −1 test/parallel/test-pipe-address.js
- +3 −2 test/parallel/test-pipe-file-to-http.js
- +2 −1 test/parallel/test-pipe-stream.js
- +2 −1 test/parallel/test-pipe-unref.js
- +2 −1 test/parallel/test-pipe-writev.js
- +6 −4 test/parallel/test-process-chdir.js
- +3 −2 test/parallel/test-process-execpath.js
- +3 −2 test/parallel/test-process-redirect-warnings-env.js
- +3 −2 test/parallel/test-process-redirect-warnings.js
- +4 −2 test/parallel/test-regress-GH-3739.js
- +3 −2 test/parallel/test-repl-history-perm.js
- +7 −6 test/parallel/test-repl-persistent-history.js
- +6 −5 test/parallel/test-repl-save-load.js
- +2 −1 test/parallel/test-repl.js
- +6 −4 test/parallel/test-require-long-path.js
- +4 −3 test/parallel/test-require-symlink.js
- +4 −3 test/parallel/test-require-unicode.js
- +3 −2 test/parallel/test-stdin-from-file.js
- +3 −2 test/parallel/test-stdout-to-file.js
- +2 −1 test/parallel/test-tls-connect-pipe.js
- +2 −1 test/parallel/test-tls-net-connect-prefer-path.js
- +2 −1 test/parallel/test-tls-wrap-econnreset-pipe.js
- +3 −2 test/parallel/test-trace-events-all.js
- +3 −2 test/parallel/test-trace-events-async-hooks.js
- +3 −2 test/parallel/test-trace-events-binding.js
- +3 −2 test/parallel/test-trace-events-category-used.js
- +3 −2 test/parallel/test-trace-events-none.js
- +4 −2 test/parallel/test-trace-events-process-exit.js
- +3 −2 test/parallel/test-trace-events-v8.js
- +3 −2 test/parallel/test-zlib-from-gzip.js
- +4 −3 test/pummel/test-fs-largefile.js
- +3 −1 test/pummel/test-fs-watch-file-slow.js
- +3 −1 test/pummel/test-fs-watch-file.js
- +3 −1 test/pummel/test-fs-watch-non-recursive.js
- +4 −2 test/pummel/test-regress-GH-814.js
- +3 −2 test/pummel/test-regress-GH-814_2.js
- +3 −1 test/pummel/test-tls-session-timeout.js
- +2 −1 test/sequential/test-async-wrap-getasyncid.js
- +3 −2 test/sequential/test-fs-readfile-tostring-fail.js
- +4 −2 test/sequential/test-fs-watch.js
- +3 −2 test/sequential/test-http2-timeout-large-write-file.js
- +2 −1 test/sequential/test-module-loading.js
- +3 −2 test/sequential/test-regress-GH-4027.js
- +4 −3 test/tick-processor/tick-processor-base.js
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @@ -6,7 +6,8 @@ const verifyGraph = require('./verify-graph'); | ||
|
|
||
| const net = require('net'); | ||
|
|
||
| const tmpdir = require('../common/tmpdir'); | ||
| tmpdir.refresh(); | ||
|
|
||
| const hooks = initHooks(); | ||
| hooks.enable(); | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @@ -0,0 +1,67 @@ | ||
| /* eslint-disable required-modules */ | ||
| 'use strict'; | ||
|
|
||
| const fs = require('fs'); | ||
| const path = require('path'); | ||
|
|
||
| function rimrafSync(p) { | ||
| let st; | ||
| try { | ||
| st = fs.lstatSync(p); | ||
| } catch (e) { | ||
| if (e.code === 'ENOENT') | ||
| return; | ||
| } | ||
|
|
||
| try { | ||
| if (st && st.isDirectory()) | ||
| rmdirSync(p, null); | ||
| else | ||
| fs.unlinkSync(p); | ||
| } catch (e) { | ||
| if (e.code === 'ENOENT') | ||
| return; | ||
| if (e.code === 'EPERM') | ||
| return rmdirSync(p, e); | ||
| if (e.code !== 'EISDIR') | ||
| throw e; | ||
| rmdirSync(p, e); | ||
| } | ||
| } | ||
|
|
||
| function rmdirSync(p, originalEr) { | ||
| try { | ||
| fs.rmdirSync(p); | ||
| } catch (e) { | ||
| if (e.code === 'ENOTDIR') | ||
| throw originalEr; | ||
| if (e.code === 'ENOTEMPTY' || e.code === 'EEXIST' || e.code === 'EPERM') { | ||
| const enc = process.platform === 'linux' ? 'buffer' : 'utf8'; | ||
| fs.readdirSync(p, enc).forEach((f) => { | ||
| if (f instanceof Buffer) { | ||
| const buf = Buffer.concat([Buffer.from(p), Buffer.from(path.sep), f]); | ||
| rimrafSync(buf); | ||
| } else { | ||
| rimrafSync(path.join(p, f)); | ||
| } | ||
| }); | ||
| fs.rmdirSync(p); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| const testRoot = process.env.NODE_TEST_DIR ? | ||
| fs.realpathSync(process.env.NODE_TEST_DIR) : path.resolve(__dirname, '..'); | ||
|
|
||
| // Using a `.` prefixed name, which is the convention for "hidden" on POSIX, | ||
| // gets tools to ignore it by default or by simple rules, especially eslint. | ||
| let tmpdirName = '.tmp'; | ||
| if (process.env.TEST_THREAD_ID) { | ||
| tmpdirName += `.${process.env.TEST_THREAD_ID}`; | ||
| } | ||
| exports.path = path.join(testRoot, tmpdirName); | ||
|
|
||
| exports.refresh = () => { | ||
| rimrafSync(exports.path); | ||
| fs.mkdirSync(exports.path); | ||
| }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.