Skip to content

Log invalid search path roots #4823

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

currenjin
Copy link

@currenjin currenjin commented Aug 9, 2025

cc. @maxandersen @marcphilipp

Summary

Detect and log non-existent, unreadable, or non-dir/jar classpath roots in ConsoleLauncher before discovery.

This change improves diagnostics when using --scan-class-path with invalid entries, addressing issue #4772.

Motivation

Currently, invalid search path roots are silently ignored, which may cause users to miss that some tests are not being discovered.

This PR makes such issues visible by logging them at INFO -> WARN level, helping users
quickly identify and fix misconfigured paths.

Changes

  • Added validateAndLogInvalidRoots() to DiscoveryRequestCreator
  • Logs invalid roots with the format:
    "Ignoring invalid search path root: %s (exists=%s, readable=%s, dirOrJar=%s)"
  • Retains the existing behaviour of skipping invalid roots
  • Added a test verifying that an invalid root triggers the log entry
  • Updated User Guide to mention this logging behaviour

Before / After Example

Before (invalid path silently ignored):

0 tests found

After:

Ignoring invalid search path root: /does/not/exist (exists=false, readable=false, dirOrJar=false)
0 tests found

Related Issue

Closes #4772


I hereby agree to the terms of the JUnit Contributor License Agreement.


Definition of Done

@sormuras sormuras changed the title feat: log invalid search path roots (#4772) Log invalid search path roots Aug 9, 2025
@sormuras
Copy link
Member

sormuras commented Aug 9, 2025

I note that javac emits the following messages for invalid entries in search paths:

warning: [path] bad path element "${PATH}": no such file or directory

@currenjin
Copy link
Author

@sormuras
Yes, exactly. This change makes the ConsoleLauncher behave more like javac in that it logs invalid classpath roots instead of silently ignoring them. While javac emits a warning to stderr, JUnit logs them at INFO level so that users can see misconfigurations during discovery.

@maxandersen
Copy link

Love it.

But should this not be WARN's ? Or as pointed out for javac - stderr message ?

@currenjin
Copy link
Author

@maxandersen

Good point. Updated the log level from INFO to WARN so that users can better notice invalid search path roots.

@currenjin
Copy link
Author

@maxandersen

Thanks for the feedback! I switched the level to WARN, but that surfaced an issue in platform-tooling-support-tests (StandaloneTests.execute*) where console output expectations are strict.

To keep the console output stable while still alerting users, would you prefer:

  1. WARN only for explicitly provided roots (e.g., via --scan-class-path <paths> or --classpath), while system-derived roots are filtered silently (or at DEBUG), or

  2. WARN for all invalid roots, but accept extra warnings on stderr and update the expected output accordingly?

I can implement (1) right away; it avoids changing the console output in common scenarios and keeps the tests green. If you’d rather go with (2), I’ll update the tests and docs.

Also, do we want to mention this behavior in the User Guide (ConsoleLauncher section)?

@currenjin
Copy link
Author

currenjin commented Aug 10, 2025

@maxandersen

Found the root cause of the test failure.

I was running the build in Korea (ko_KR locale), and the execute-related tests did not explicitly set the language.
This caused JUL log levels in the output to be localized (INFO → 정보), so the expected-err.txt assertions failed.

I fixed this by forcing -Duser.language=en and -Duser.country=US in the relevant tests.

@currenjin currenjin force-pushed the feat/issue-4772-log-invalid-roots branch from 744c29a to cb782d9 Compare August 10, 2025 10:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add logging to have console launcher inform about bad/missing searchpath roots
3 participants