-
-
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
Feature/temp dir cleanup #2729
Feature/temp dir cleanup #2729
Conversation
…, as this could lead to indeterminate cleanup mode
…it works just fine
Codecov Report
@@ Coverage Diff @@
## main #2729 +/- ##
===========================================
+ Coverage 0 91.07% +91.07%
- Complexity 0 4476 +4476
===========================================
Files 0 385 +385
Lines 0 10846 +10846
Branches 0 845 +845
===========================================
+ Hits 0 9878 +9878
- Misses 0 744 +744
- Partials 0 224 +224
Continue to review full report at Codecov.
|
@hglasgow Sorry for the wait!
I think we should be able to pass the |
All done, ready for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I found one additional minor thing.
@AfterAll | ||
static void afterAll() { | ||
if (defaultParameterDir != null && defaultParameterDir.exists()) { | ||
defaultParameterDir.delete(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File.delete
returns a false
if the file wasn't deleted for some reason. Instead, I think we should use Files.deleteIfExists
(and Path
in the test cases) which only returns false
if the file didn't exists and throws an exception if there was a problem deleting it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, that's done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ready for review
...piter-engine/src/test/java/org/junit/jupiter/engine/extension/TempDirectoryCleanupTests.java
Outdated
Show resolved
Hide resolved
documentation/src/docs/asciidoc/release-notes/release-notes-5.9.0-M1.adoc
Outdated
Show resolved
Hide resolved
...piter-engine/src/test/java/org/junit/jupiter/engine/extension/CloseablePathCleanupTests.java
Outdated
Show resolved
Hide resolved
...piter-engine/src/test/java/org/junit/jupiter/engine/extension/CloseablePathCleanupTests.java
Show resolved
Hide resolved
…9.0-M1.adoc Co-authored-by: Marc Philipp <marc@gradle.com>
Co-authored-by: Marc Philipp <marc@gradle.com>
Co-authored-by: Marc Philipp <marc@gradle.com>
…tension/TempDirectoryCleanupTests.java Co-authored-by: Marc Philipp <marc@gradle.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! 👍
This PR adds a cleanup mode (`ALWAYS` (default), `ON_SUCCESS`, or `NEVER`) parameter to `@TempDir` that allows to configured when the temp directory should be deleted. The default can be configured by setting a configuration parameter. Resolves junit-team#2159. Co-authored-by: Marc Philipp <mail@marcphilipp.de>
- Use correct versions in @SInCE tags and @API declarations - Add missing @SInCE tags and @API declarations - Add missing Javadoc - Fix configuration parameter name for default cleanup mode - Clarify meaning of DEFAULT cleanup mode - Improve Javadoc - Polish tests See junit-team#2729
Prior to this commit, a custom default cleanup mode was ignored when determining the cleanup mode for a parameter annotated with @tempdir. See junit-team#2729
Overview
Addressing issue #2159 .
This PR adds a TempDirStrategy annotation for managing TempDirs. The annotation has a single CleanupMode enum field that can have a value of ALWAYS or NEVER. If the field is NEVER, then a test class's TempDirs are not cleaned up after the test completes. The annotation also works on nested classes, and a config parameter for the default cleanup mode has been added. Unit tests, demo and documentation included.
The issue discussion included the idea of an 'on_success' mode, but I have been unable to work out how to achieve this. Happy to discuss ideas on how this might be done.
I hereby agree to the terms of the JUnit Contributor License Agreement.
Definition of Done
@API
annotations