Skip to content
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

Use a random ${test:logging.path} #2954

Open
wants to merge 1 commit into
base: 2.x
Choose a base branch
from

Conversation

ppkarwasz
Copy link
Contributor

The @TempLoggingDir JUnit 5 extensions create a totally deterministic directory to hold the log files for tests.

Since the directory is deleted only if all the tests succeed, this causes a problem with test reruns.

The `@TempLoggingDir` JUnit 5 extensions create a totally deterministic directory to hold the log files for tests.

Since the directory is deleted only if all the tests succeed, this causes a problem with test reruns.
@ppkarwasz ppkarwasz self-assigned this Sep 16, 2024
@@ -51,7 +51,8 @@ public void beforeAll(ExtensionContext context) throws Exception {
Path loggingPath = null;
for (final Field field : fields) {
if (loggingPath != null) {
StatusLogger.getLogger().warn("Multiple fields with @TempLoggingDir annotation are not supported.");
StatusLogger.getLogger()
.warn("Multiple static fields with @TempLoggingDir annotation are not supported.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're salting the generated paths, why not?

@@ -78,7 +79,8 @@ public void beforeEach(ExtensionContext context) throws Exception {
final Object instance = context.getRequiredTestInstance();
for (final Field field : fields) {
if (loggingPath != null) {
StatusLogger.getLogger().warn("Multiple fields with @TempLoggingDir annotation are not supported.");
StatusLogger.getLogger()
.warn("Multiple instance fields with @TempLoggingDir annotation are not supported.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, why not?

// Create a temporary directory that uses the simple class name as prefix
Path packagePath = basePath.resolve(dir);
Files.createDirectories(packagePath);
return Files.createTempDirectory(packagePath, clazz.getSimpleName());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we suffix the path with something that will make directories lexicographically sorted by their creation time, please? For instance, timestamp + counter + salt, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants