Copilot commented on code in PR #3543:
URL: https://github.com/apache/maven-surefire/pull/3543#discussion_r4549933985
##########
maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/DefaultForkConfiguration.java:
##########
@@ -226,24 +226,28 @@ private File getWorkingDirectory(int forkNumber) throws
SurefireBooterForkExcept
* to evaluation when the pom is parsed as is done with
<pre>${property-name}</pre> expressions).
*
* This allows other plugins to modify or set properties with the changes
getting picked up by surefire.
+ *
+ * @param argLine the configured argLine, may be {@code null}
+ * @param modelProperties the properties of the project model
+ * @return the trimmed argLine with its placeholders replaced, or an empty
string if there is no argLine
*/
@Nonnull
- private String interpolateArgLineWithPropertyExpressions() {
- if (getArgLine() == null) {
+ public static String interpolateArgLineWithPropertyExpressions(
Review Comment:
Making `interpolateArgLineWithPropertyExpressions` `public static` on
`DefaultForkConfiguration` exposes an internal helper as part of a public API
surface. If this is only intended for internal reuse, consider moving the
helper to an internal/shared utility type (or a package-private class in a
suitable package), or otherwise constrain visibility to avoid locking in this
method signature on a public class.
##########
maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoTest.java:
##########
@@ -2063,6 +2064,76 @@ public void
shouldNotWarnWhenIgnoredParametersKeepTheirDefaults() {
verify(logger, times(0)).warn(anyString());
}
+ @Test
+ public void shouldFailWhenArgLineIsSetAndNotForking() {
+ givenProjectWithModelProperties(new Properties());
+ mojo.forkCount = "0";
+ mojo.setArgLine("-javaagent:jacocoagent.jar");
+
+ Exception e = assertThrows(Exception.class, () -> invokeMethod(mojo,
"ensureNoArgLineWhenNotForking"));
Review Comment:
This assertion is overly broad (`Exception.class`), which reduces the test’s
precision and can hide unexpected failures. Consider asserting the specific
exception type thrown by `invokeMethod` (commonly `InvocationTargetException`
for reflective invocation) and then asserting on its cause, so the test fails
fast if the failure mechanism changes unexpectedly.
##########
surefire-its/src/test/java/org/apache/maven/surefire/its/SystemPropertiesTestIT.java:
##########
@@ -43,7 +43,8 @@ public void testSystemPropertiesNoFork() {
unpack().forkNever()
.addGoal("-DsetOnMavenCommandLine=baz")
.addGoal("-DsetOnArgLineWorkAround=baz")
- // DGF fake the argLine, since we're not forking
+ // DGF fake the argLine, since we're not forking: clear it and
set its property on the Maven JVM
Review Comment:
The updated comment still contains the unexplained acronym `DGF`, which
makes the intent harder to understand for readers unfamiliar with the history.
Consider rewriting the comment without the acronym (e.g., directly describing
that the test clears `argLine` and sets the equivalent system property on the
Maven JVM when not forking).
--
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]