Conversation
Exclude bin and out directories from file search and prefer paths containing "src" when multiple matches are found. Throw an error when the source file location is still ambiguous. Closes #200
There was a problem hiding this comment.
Pull request overview
This PR addresses issue #200 where test source files were sometimes incorrectly referenced from build output directories (like bin) instead of actual source directories. The solution adds exclusions for bin and out directories, implements a disambiguation strategy that prefers paths containing src, and provides clear error messages when the source file cannot be found or is ambiguous.
Changes:
- Extended the directory exclusion regex pattern to exclude
binandoutdirectories in addition tobuildandtarget - Replaced the "first match wins" strategy with a comprehensive disambiguation approach that collects all matches and prefers paths containing
srcwhen multiple matches exist - Added descriptive error handling for missing and ambiguous source file scenarios
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| modules/core/src/main/java/org/approvej/approve/StackTraceTestFinderUtil.java | Updated path filtering regex to exclude bin and out directories; replaced simple first-match logic with disambiguation strategy that prefers src paths |
| modules/core/src/test/java/org/approvej/approve/StackTraceTestFinderUtilTest.java | Added comprehensive tests for bin directory exclusion, missing source files, src path preference, and ambiguous path scenarios |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
modules/core/src/main/java/org/approvej/approve/StackTraceTestFinderUtil.java
Outdated
Show resolved
Hide resolved
modules/core/src/main/java/org/approvej/approve/StackTraceTestFinderUtil.java
Outdated
Show resolved
Hide resolved
modules/core/src/test/java/org/approvej/approve/StackTraceTestFinderUtilTest.java
Show resolved
Hide resolved
Use path separator in negative lookahead to avoid excluding directories that merely start with excluded names. Include src match count in ambiguity error message. Add out directory to parameterized test.
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "Found multiple test source files (%d contain 'src'): %s" | ||
| .formatted(srcMatches.size(), matches)); |
There was a problem hiding this comment.
The error message indicates how many paths contain 'src' but then shows all matches. This could be confusing if srcMatches.size() differs from matches.size(). Consider either showing only srcMatches in the error message, or clarifying that all matches are being shown. For example: "Found multiple test source files (%d total, %d contain 'src'): %s".formatted(matches.size(), srcMatches.size(), matches)
| "Found multiple test source files (%d contain 'src'): %s" | |
| .formatted(srcMatches.size(), matches)); | |
| "Found multiple test source files (%d total, %d contain 'src'): %s" | |
| .formatted(matches.size(), srcMatches.size(), matches)); |



Summary
binandoutdirectories from test source file search (fixes IntelliJ copying sources intobin)srcwhen multiple matches are found, resolving ambiguity from output directories not explicitly excludedCloses #200
Test plan
buildandtargetexclusion still passbindirectory exclusionsrcpath preference when multiple matches existsrcmatches) throwing error