Skip to content

Commit b569105

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 <rtrott@gmail.com> Reviewed-By: Zijian Liu <lxxyxzj@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
1 parent d039e6f commit b569105

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
@@ -945,13 +945,18 @@ The realpath of the testing temporary directory.
945945

946946
Deletes and recreates the testing temporary directory.
947947

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

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

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

0 commit comments

Comments
 (0)