You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "SwatiKumari250 (via GitHub)" <gi...@apache.org> on 2026/10/14 16:20:54 UTC
[PR] Fix/2795 excluded groups no tests [maven-surefire]
SwatiKumari250 opened a new pull request, #3528:
URL: https://github.com/apache/maven-surefire/pull/3528
<!-- Add your description here... what, why and how you resolve the issue -->
---
To make clear that you license your contribution under
the [Apache License Version 2.0, January 2004](https://www.apache.org/licenses/LICENSE-2.0)
check one of the following:
- [ ] I hereby declare this contribution to be licensed under the [Apache License Version 2.0, January 2004](https://www.apache.org/licenses/LICENSE-2.0)
- [ ] I hereby declare that I have filed an [Apache Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
--
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix/2795 excluded groups no tests [maven-surefire]
Posted by "olamy (via GitHub) via issues" <is...@maven.apache.org>.
olamy commented on PR #3528:
URL: https://github.com/apache/maven-surefire/pull/3528#issuecomment-6657191545
Hi @SwatiKumari250, thanks for picking this up, the diff reads nicely.
I went a slightly different way in #3570: the groups check now runs after the
test scan, so it only fires when there are tests to run. That also covers a
case yours didn't, where src/test holds only helper classes. Those do compile
to .class files, but they aren't tests.
So I'm closing this in favour of #3570. The resources-only case you spotted is
covered there with an IT of its own. Thanks again, hope to see more from you.
--
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix/2795 excluded groups no tests [maven-surefire]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #3528:
URL: https://github.com/apache/maven-surefire/pull/3528#issuecomment-6172995779
<!-- license-declaration-check -->
### ⚠️ License declaration missing
The pull request description must contain at least one of the following lines with a **checked** box (`[x]`):
```markdown
- [ ] I hereby declare this contribution to be licensed under the [Apache License Version 2.0, January 2004](https://www.apache.org/licenses/LICENSE-2.0)
- [ ] I hereby declare that I have filed an [Apache Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
```
This comment will be hidden automatically once the description is fixed.
--
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix/2795 excluded groups no tests [maven-surefire]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #3528:
URL: https://github.com/apache/maven-surefire/pull/3528#discussion_r4346495889
##########
maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java:
##########
@@ -3015,6 +3019,29 @@ private void warnIfDefunctGroupsCombinations() throws MojoFailureException, Mojo
}
}
+ private boolean containsTestClasses(File directory) {
+ if (directory == null) {
+ return false;
+ }
+
+ File[] files = directory.listFiles();
Review Comment:
This scan allocates a `File[]` for every directory visited and may traverse large trees under `target/test-classes`, which can add noticeable overhead on big projects. A more efficient approach is to use NIO streaming traversal (so you can short-circuit without materializing entire directory listings) or at least filter `listFiles` to only directories and `*.class` to reduce allocations.
##########
maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java:
##########
@@ -3015,6 +3019,29 @@ private void warnIfDefunctGroupsCombinations() throws MojoFailureException, Mojo
}
}
+ private boolean containsTestClasses(File directory) {
+ if (directory == null) {
+ return false;
+ }
+
+ File[] files = directory.listFiles();
+ if (files == null) {
+ return false;
+ }
+
+ for (File file : files) {
+ if (file.isDirectory()) {
+ if (containsTestClasses(file)) {
+ return true;
+ }
+ } else if (file.getName().endsWith(".class")) {
+ return true;
+ }
+ }
+
+ return false;
Review Comment:
This recursive traversal can follow directory symlinks (depending on platform/filesystem), which can lead to cycles (infinite recursion) or very deep recursion (stack overflow) in unusual but real-world layouts. Consider switching to `java.nio.file.Files.walk(...)`/`walkFileTree(...)` without following links and using an early-terminating `anyMatch`/visitor to keep the scan bounded and robust.
##########
maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java:
##########
@@ -3015,6 +3019,29 @@ private void warnIfDefunctGroupsCombinations() throws MojoFailureException, Mojo
}
}
+ private boolean containsTestClasses(File directory) {
+ if (directory == null) {
+ return false;
+ }
+
+ File[] files = directory.listFiles();
+ if (files == null) {
+ return false;
+ }
+
+ for (File file : files) {
Review Comment:
This scan allocates a `File[]` for every directory visited and may traverse large trees under `target/test-classes`, which can add noticeable overhead on big projects. A more efficient approach is to use NIO streaming traversal (so you can short-circuit without materializing entire directory listings) or at least filter `listFiles` to only directories and `*.class` to reduce allocations.
##########
maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoTest.java:
##########
@@ -1949,6 +1949,14 @@ protected File[] getSuiteXmlFiles() {
mojo.ensureNoSuiteXmlFiles();
}
+ @Test
Review Comment:
The PR description appears to still contain the default template placeholder text and the Apache License/ICLA checkbox section is left unchecked. Please update the PR description to explain the change and select the appropriate licensing checkbox so the submission metadata is complete.
##########
maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoTest.java:
##########
@@ -1949,6 +1949,14 @@ protected File[] getSuiteXmlFiles() {
mojo.ensureNoSuiteXmlFiles();
}
+ @Test
+ public void shouldNotValidateGroupsWhenNoTestClassesExist() throws Exception {
+ mojo.setTestClassesDirectory(tempFolder.toFile());
+ setInternalState(mojo, "excludedGroups", "SlowTest");
+
+ invokeMethod(mojo, "warnIfDefunctGroupsCombinations");
+ }
Review Comment:
This test currently has no explicit assertion and relies on the absence of an exception. Making the intent explicit (e.g., using an `assertDoesNotThrow`-style assertion around `invokeMethod(...)`) will improve readability and ensure the test continues to clearly document the expected 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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix/2795 excluded groups no tests [maven-surefire]
Posted by "olamy (via GitHub) via issues" <is...@maven.apache.org>.
olamy closed pull request #3528: Fix/2795 excluded groups no tests
URL: https://github.com/apache/maven-surefire/pull/3528
--
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org