-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@TempDir cleanup does not handle Windows junctions correctly #4299
Comments
Some extra info:
So you can do the following to detect a broken junction (or any broken link):
If you want to test if path points to a link you can also do something like the following:
|
PS: if we add an extra |
It's doing exactly that: 🤔 junit5/junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/extension/TempDirectory.java Line 485 in 6430ba4
|
I submitted a draft PR (#4301) with your test case to see if the issue can be reproduced on the Windows runner of GitHub Actions because I don't currently have a Windows machine available. |
I've added some logging and the problem seems to be that Java fails to create a
which is then seen as "nothing to do" and ignored here: junit5/junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/extension/TempDirectory.java Lines 409 to 418 in f9b1ff6
|
Awesome! |
Using junit 5.11.4
It's a very specific situation but the cleanup of a directory created with
@TempDir
will fail on Windows if it contains junctions that point to a directory that no longer exists. The following code reproduces the issue:Why are junctions used instead of plain symbolic (or hard) links? Well on Windows you need special privileges to create links which not everybody has, while junctions are allowed by default. (Btw, junctions can only be used for directories, not files!)
Perhaps the easiest way to solve this would be to add an
ignoreCleanupErrors
options to@TempDir
, which would continue trying to delete files and not throw any errors, because not being able to fully delete a temp folder might not be seen as a test failure in many cases. (But of course junit should also be able to handle this situation properly and delete broken junctions).The text was updated successfully, but these errors were encountered: