-
-
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
Merged
Merged
Feature/temp dir cleanup #2729
Changes from all commits
Commits
Show all changes
57 commits
Select commit
Hold shift + click to select a range
71d885e
Add TempDirCleanupStrategy, and plumb into config, and tests.
b90db93
Fix style problem
dca9fca
Fix style problem
900ec13
Set a default value for the cleanup mode of ALWAYS
5c6028c
Rename to TempDirStrategy to provide for more potential flexibility o…
d295303
Spotless fix of * imports
2242f47
Spotless fix of indentation
3019634
Spotless fix of indentation
313fd6b
Spotless fix of indentation
e596f0b
Spotless fix of indentation
118ffe7
Get Always and Never tests passing
ed98bc1
Spotless fix of indentation
476ba11
Spotless fix of indentation
099aed9
Move to version 5.9
ede3aee
Prevent TempDirStrategy annotations from being added to inner classes…
4934c90
Allow TempDirStrategy annotations from being added to inner classes, …
5209310
Remove ON_SUCCESS cleanup mode, and add demo test for documentation
73821e6
Add lifecycle tests for temp directory cleanup in different modes
bbfdf18
Add lifecycle tests for temp directory cleanup of nested tests
87e2be1
Add documentation for TempDirStrategy
2c63046
Use static imports of CleanupMode
29e4d0e
Apply spotless corrections
a15cae6
Documentation of the cleanup.mode.default configuration parameter
eafc5c1
Documentation; configuration parameters link
1fc600c
Fix @API problem
4dcaef5
Fix @API problem
5b09b66
Move to CleanupMode parameter in TempDir.
90d2a75
Typo
f9e67f6
Make CloseablePath responsive to ON_SUCCESS, and unit test.
13abd0d
Set cleanup mode for injected TempDir fields, and tests.
6ce9387
Rename
e6363b7
Add API annotation to CleanupMode
bf1fdf4
Spotless
47a9655
Use configured cleanup mode if none defined.
5e8c72e
Final polish
825991a
Address easy parts of review changes
da487dc
AnnotationSupport fix
056f08d
Better parameter resolution, and test.
5b4451c
Inject and use JupiterConfiguration
0fa4415
Move DEFAULT_TEST_CLASS_ORDER_PROPERTY_NAME
90eeee2
Move DEFAULT_TEST_CLASS_ORDER_PROPERTY_NAME
38ef09f
Fix accidental class rename, and update release documentation.
66cec30
Move TempDirectory out of stateless extension list.
66577d9
Cleanup test directories.
05afc2b
Add TempDir parameter tests.
33cd7e6
Rework TempDirectoryParameterResolverTests using AbstractJupiterTestE…
56118f0
Retrigger build.
c32ccba
Retrigger build.
a18d400
Use nio for safer deletes.
05b5f17
Update documentation/src/docs/asciidoc/release-notes/release-notes-5.…
1311ce0
Update documentation/src/docs/asciidoc/user-guide/writing-tests.adoc
9894363
Update documentation/src/docs/asciidoc/user-guide/writing-tests.adoc
7b6a36d
Update junit-jupiter-engine/src/test/java/org/junit/jupiter/engine/ex…
32f9094
Simplify parameter directory deletion.
682463e
Simplify closeable path deletion.
55aabfe
Clean up the temp directory after use.
85493ee
Rerun build.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
documentation/src/test/java/example/TempDirCleanupModeDemo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright 2015-2021 the original author or authors. | ||
* | ||
* All rights reserved. This program and the accompanying materials are | ||
* made available under the terms of the Eclipse Public License v2.0 which | ||
* accompanies this distribution and is available at | ||
* | ||
* https://www.eclipse.org/legal/epl-v20.html | ||
*/ | ||
|
||
package example; | ||
|
||
import static org.junit.jupiter.api.io.CleanupMode.ON_SUCCESS; | ||
|
||
import java.nio.file.Path; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.io.TempDir; | ||
|
||
// tag::user_guide[] | ||
class TempDirCleanupModeDemo { | ||
|
||
@Test | ||
void fileTest(@TempDir(cleanup = ON_SUCCESS) Path tempDir) { | ||
// perform test | ||
} | ||
} | ||
// end::user_guide[] |
50 changes: 50 additions & 0 deletions
50
junit-jupiter-api/src/main/java/org/junit/jupiter/api/io/CleanupMode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright 2015-2021 the original author or authors. | ||
* | ||
* All rights reserved. This program and the accompanying materials are | ||
* made available under the terms of the Eclipse Public License v2.0 which | ||
* accompanies this distribution and is available at | ||
* | ||
* https://www.eclipse.org/legal/epl-v20.html | ||
*/ | ||
|
||
package org.junit.jupiter.api.io; | ||
|
||
import static org.apiguardian.api.API.Status.EXPERIMENTAL; | ||
|
||
import org.apiguardian.api.API; | ||
|
||
/** | ||
* Enumeration of cleanup modes for a {@code TempDir}. | ||
* | ||
* <p>When a test with a temporary directory completes, it might be useful in | ||
* some cases to be able to view the contents of the directory resulting from | ||
* the test. {@code CleanupMode} allows control of how a {@code TempDir} | ||
* is cleaned up. | ||
* | ||
* @since 5.4 | ||
* @see TempDir | ||
*/ | ||
@API(status = EXPERIMENTAL, since = "5.4") | ||
public enum CleanupMode { | ||
|
||
/** | ||
* Defer to the configured cleanup mode. | ||
*/ | ||
DEFAULT, | ||
|
||
/** | ||
* Always clean up a temporary directory after the test has completed. | ||
*/ | ||
ALWAYS, | ||
|
||
/** | ||
* Don't clean up a temporary directory after the test has completed. | ||
*/ | ||
NEVER, | ||
|
||
/** | ||
* Only clean up a temporary directory if the test completed successfully. | ||
*/ | ||
ON_SUCCESS | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
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.
As far as I can see this is not used. Please inject
JupiterConfiguration
intoTempDirectory
when registering default extensions inMutableExtensionRegistry
.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.
Now injected and referenced in TempDirectory