arturobernalg opened a new pull request, #3598:
URL: https://github.com/apache/maven-surefire/pull/3598
Fixes #2255.
`matchClassRegexPatter` converted `testClassFile`'s separator to the
platform's (replacing `/` with `\` on Windows) but left `classPattern` -- the
user's `%regex[...]` expression -- untouched, so a pattern like `%regex[it/.*]`
could never match on Windows: the file path had backslashes, the pattern still
had a literal forward slash.
Both sides are documented to always use forward slashes, even on Windows
(`inclusion-exclusion.md.vm`: "Slashes here are forward, even on Windows"), and
`testClassFile` is in fact always built with a literal `/` (`FileScanner`),
never `File.separator` -- so unlike `matchClassPatter`, which legitimately
converts both sides for its non-regex Ant-style patterns, there's nothing to
convert here at all.
Verified the root cause against the real matching library directly:
`MatchPatterns.from("%regex[it/.*]").matches("it/ExampleIntegrationTest.class",
true)` returns `true`, but `.matches("it\\ExampleIntegrationTest.class", true)`
(what the buggy code produces on Windows) returns `false` -- confirming the
library itself does a literal match with no separator normalization, so the bug
is entirely in this method's own conversion. No existing test on Linux/macOS
can fail on the old code (`separatorChar == '/'` makes the conversion a no-op
there, exactly why this slipped through for 8 years since SUREFIRE-1275), so I
added a unit test that locks in the documented forward-slash contract rather
than one that only fails on Windows.
Ran the full `surefire-api` suite, checkstyle and spotless locally, all
green.
To make clear that you license your contribution under the Apache License
Version 2.0, January 2004, check one of the following:
- [x] I hereby declare this contribution to be licensed under the Apache
License Version 2.0, January 2004
- [x] I hereby declare that I have filed an Apache Individual Contributor
License Agreement.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]