Copilot commented on code in PR #3554:
URL: https://github.com/apache/maven-surefire/pull/3554#discussion_r4441629085
##########
surefire-api/src/main/java/org/apache/maven/surefire/api/testset/ResolvedTest.java:
##########
@@ -307,7 +309,11 @@ static String fromFullyQualifiedClass(String cls) {
} else if (!cls.contains("/")) {
if (cls.endsWith(WILDCARD_FILENAME_POSTFIX)) {
String clsName = cls.substring(0, cls.length() -
WILDCARD_FILENAME_POSTFIX.length());
- return clsName.contains(".") ? clsName.replace('.', '/') +
WILDCARD_FILENAME_POSTFIX : cls;
+ if (!clsName.contains(".")) {
+ return cls;
Review Comment:
This early return leaves single-segment package wildcards broken: `dev.*`
remains a filename pattern and cannot match `dev/MyTest.class`, although
`dev/*` can. Handle single-segment packages too, while preserving unqualified
class-pattern matching, and add a regression test.
##########
surefire-api/src/main/java/org/apache/maven/surefire/api/testset/ResolvedTest.java:
##########
@@ -307,7 +309,11 @@ static String fromFullyQualifiedClass(String cls) {
} else if (!cls.contains("/")) {
if (cls.endsWith(WILDCARD_FILENAME_POSTFIX)) {
String clsName = cls.substring(0, cls.length() -
WILDCARD_FILENAME_POSTFIX.length());
- return clsName.contains(".") ? clsName.replace('.', '/') +
WILDCARD_FILENAME_POSTFIX : cls;
+ if (!clsName.contains(".")) {
+ return cls;
+ }
+ String path = clsName.replace('.', '/');
+ return isPackageName(clsName) ? path +
WILDCARD_PACKAGE_POSTFIX : path + WILDCARD_FILENAME_POSTFIX;
Review Comment:
Selecting the interpretation by capitalization breaks valid existing
selectors: `org.example.lowerTest.*` no longer matches
`org/example/lowerTest.class`, so exclusions can silently stop excluding that
class. It also leaves package selectors such as `org.Example.*` and
`testng.*.*` unsupported. Preserve the legacy class-file match while adding the
package match, rather than choosing one by capitalization, and cover both
inclusion and exclusion behavior.
--
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]