-
-
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
Let @TempDir
fail fast if createTempDirectory
does not return a directory
#3901
Let @TempDir
fail fast if createTempDirectory
does not return a directory
#3901
Conversation
b7e8586
to
5ad2075
Compare
f8a4fa4
to
004ca27
Compare
004ca27
to
e5815e0
Compare
@TempDir
fail fast if createTempDirectory
returns null
If you can update this to reflect #3902 as well, we can hopefully get this into 5.11 RC1. |
Hi @sbrannen / team, I'm considering changing the testing strategy for these changes. For the non-nullability check, I introduced additional integration tests in both However, now that the directory requirement should be tested and I want to cover both regular files and symbolic links, there is probably little value in having such a duplication. It might be enough to unit test Which direction do you prefer? |
I would change the tests you added to check for "not a directory" (not important whether it's |
@TempDir
fail fast if createTempDirectory
returns null
@TempDir
fail fast if createTempDirectory
does not return a directory
@scordio We'd like to release 5.11 RC1 tomorrow. Do you have time today to make the requested changes? If not, please let me know so I can finish it. |
@marcphilipp yes, I have time 🙂 |
@marcphilipp anything against adding |
Unfortunately, yes, since that will break Eclipse which will create a cyclic project dependency since junit-jupiter-params has a test runtime dependency on junit-jupiter-engine. I also wanted to do this last week. For now, please use a dynamic test. Maybe we should introduce a |
junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/extension/TempDirectory.java
Show resolved
Hide resolved
In the end I opted for standard tests, as the setup and cleanup differ between each test case. |
@@ -60,7 +60,8 @@ repository on GitHub. | |||
`assertInstanceOf` methods introduced in `5.8` version. | |||
* New generators in `DynamicTest` that take a `Stream`/`Iterator` of `Named<Executable>` | |||
along with a convenient `NamedExecutable` interface that can simplify writing dynamic | |||
tests, in particular in recent version of Java that support records. | |||
tests, in particular in recent versions of Java that support records. |
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 for fixing my typo! 👍
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.
Oh, thanks for catching the release notes gap!
documentation/src/docs/asciidoc/release-notes/release-notes-5.11.0-RC1.adoc
Outdated
Show resolved
Hide resolved
@@ -137,7 +137,7 @@ static class JimfsTempDirFactory implements TempDirFactory { | |||
@Override | |||
public Path createTempDirectory(AnnotatedElementContext elementContext, ExtensionContext extensionContext) | |||
throws IOException { | |||
return Files.createTempDirectory(fileSystem.getPath("/"), "junit"); | |||
return Files.createTempDirectory(fileSystem.getPath("/"), "junit-"); |
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.
👍
@scordio Thanks for your quick and high-quality work on this! 👍 |
private CloseablePath(TempDirFactory factory, CleanupMode cleanupMode, AnnotatedElementContext elementContext, | ||
ExtensionContext extensionContext) throws Exception { | ||
this.dir = factory.createTempDirectory(elementContext, extensionContext); | ||
this.dir = validateTempDirectory(factory.createTempDirectory(elementContext, extensionContext)); | ||
this.factory = factory; | ||
this.cleanupMode = cleanupMode; | ||
this.extensionContext = extensionContext; | ||
} |
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.
@marcphilipp I just realized a PreconditionViolationException
thrown in the constructor would interrupt the execution without closing the factory.
Should we wrap it in a try/catch?
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.
I raised #3911 for evaluation.
Overview
Resolves #3900.
I hereby agree to the terms of the JUnit Contributor License Agreement.
Definition of Done
@API
annotations