Skip to content

Commit 776ef11

Browse files
RaisinTentargos
authored andcommitted
test: clarify usage of tmpdir.refresh()
This emphasizes that `tmpdir.refresh()` must be called only once in each test file when needed. PR-URL: #37383 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Zijian Liu <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
1 parent 51ef745 commit 776ef11

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

test/common/README.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -944,13 +944,18 @@ The realpath of the testing temporary directory.
944944

945945
Deletes and recreates the testing temporary directory.
946946

947-
The first time `refresh()` runs, it adds a listener to process `'exit'` that
947+
The first time `refresh()` runs, it adds a listener to process `'exit'` that
948948
cleans the temporary directory. Thus, every file under `tmpdir.path` needs to
949949
be closed before the test completes. A good way to do this is to add a
950950
listener to process `'beforeExit'`. If a file needs to be left open until
951951
Node.js completes, use a child process and call `refresh()` only in the
952952
parent.
953953

954+
It is usually only necessary to call `refresh()` once in a test file.
955+
Avoid calling it more than once in an asynchronous context as one call
956+
might refresh the temporary directory of a different context, causing
957+
the test to fail somewhat mysteriously.
958+
954959
## UDP pair helper
955960

956961
The `common/udppair` module exports a function `makeUDPPair` and a class

0 commit comments

Comments
 (0)