This is an automated email from the ASF dual-hosted git repository. slachiewicz pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven-checkstyle-plugin.git
commit 78540bc19d4aafccca443a1c508a087a6f2aaccc Author: Sylwester Lachiewicz <[email protected]> AuthorDate: Thu Nov 5 00:53:14 2026 +0000 Bind the blank violationIgnore through the harness and note the JVM-wide test state --- .../checkstyle/CheckstyleViolationCheckScenarioTest.java | 12 +++++------- .../maven/plugins/checkstyle/StandardErrorCapture.java | 2 ++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/test/java/org/apache/maven/plugins/checkstyle/CheckstyleViolationCheckScenarioTest.java b/src/test/java/org/apache/maven/plugins/checkstyle/CheckstyleViolationCheckScenarioTest.java index 111df6f..ed4f1ee 100644 --- a/src/test/java/org/apache/maven/plugins/checkstyle/CheckstyleViolationCheckScenarioTest.java +++ b/src/test/java/org/apache/maven/plugins/checkstyle/CheckstyleViolationCheckScenarioTest.java @@ -30,6 +30,7 @@ import java.util.regex.Pattern; import org.apache.maven.api.di.Provides; import org.apache.maven.api.plugin.testing.Basedir; import org.apache.maven.api.plugin.testing.InjectMojo; +import org.apache.maven.api.plugin.testing.MojoParameter; import org.apache.maven.api.plugin.testing.MojoTest; import org.apache.maven.model.Build; import org.apache.maven.plugin.MojoExecutionException; @@ -54,6 +55,9 @@ import static org.junit.jupiter.api.Assertions.assertTrue; * <p> * The log of the plugin is recorded. The executor logs through SLF4J instead, so what it writes to * <code>System.err</code> is captured as well (<code>simplelogger.properties</code> enables its debug level). + * <p> + * Some tests change the JVM-wide default locale and standard error stream, so this class must not run its tests in + * parallel with others; the build runs them sequentially. */ @MojoTest public class CheckstyleViolationCheckScenarioTest { @@ -110,10 +114,10 @@ public class CheckstyleViolationCheckScenarioTest { /** MCHECKSTYLE-347: a blank violationIgnore ignores nothing. */ @Basedir("/check-scenarios/MCHECKSTYLE-347") @InjectMojo(goal = "check", pom = "pom.xml") + @MojoParameter(name = "violationIgnore", value = "") @Test public void testBlankViolationIgnore(CheckstyleViolationCheckMojo mojo) throws Exception { project.addCompileSourceRoot("src/main/java"); - setViolationIgnore(mojo, ""); Execution execution = execute(mojo); @@ -313,12 +317,6 @@ public class CheckstyleViolationCheckScenarioTest { return messages.toString(); } - private static void setViolationIgnore(CheckstyleViolationCheckMojo mojo, String value) throws Exception { - java.lang.reflect.Field field = CheckstyleViolationCheckMojo.class.getDeclaredField("violationIgnore"); - field.setAccessible(true); - field.set(mojo, value); - } - private String readResult(CheckstyleViolationCheckMojo mojo) throws Exception { File outputFile = (File) org.apache.maven.api.plugin.testing.MojoExtension.getVariableValueFromObject(mojo, "outputFile"); diff --git a/src/test/java/org/apache/maven/plugins/checkstyle/StandardErrorCapture.java b/src/test/java/org/apache/maven/plugins/checkstyle/StandardErrorCapture.java index 4a08711..bc54e36 100644 --- a/src/test/java/org/apache/maven/plugins/checkstyle/StandardErrorCapture.java +++ b/src/test/java/org/apache/maven/plugins/checkstyle/StandardErrorCapture.java @@ -25,6 +25,8 @@ import java.io.UnsupportedEncodingException; /** * Captures what is written to the standard error stream, where the SLF4J binding of the tests writes the log of * the Checkstyle executor. + * <p> + * Replaces <code>System.err</code> for the whole JVM until closed, so it is only safe while tests run sequentially. */ final class StandardErrorCapture implements AutoCloseable {
