test: Fix windows_spawn tmp directory cleanup #15471
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
On Windows, a directory that's set as the current working directory is not allowed to be removed. This can cause error on
deleteTree
if the CWD is set to the handle to be removed and will result inerror.FileBusy
. However, due totmp.cleanup()
ignoring the errors, the folder removal error will be ignored. (Possibly Related: #15465)The only test that I found to be violating this is
windows_spawn
as it sets CWD to the tmp dir then tries to remove it. I added a test to verify this occurrence.Another option for solving is to always set the CWD to the parent in both
cleanup()
functions:zig/lib/std/testing.zig
Lines 520 to 525 in 7285eed
I hate to take another guess, but this * might be * be the last test causing the random CI timeouts on Windows (#14948) as it was also re-enabled on #14647 . However, I believe when #15467 is merged, it could also mitigate these from happening all together.