diff --git a/pitest-maven/src/main/java/org/pitest/maven/SurefireConfigConverter.java b/pitest-maven/src/main/java/org/pitest/maven/SurefireConfigConverter.java index c1b5ceaab..40da3bdb4 100644 --- a/pitest-maven/src/main/java/org/pitest/maven/SurefireConfigConverter.java +++ b/pitest-maven/src/main/java/org/pitest/maven/SurefireConfigConverter.java @@ -29,6 +29,7 @@ public ReportOptions update(ReportOptions option, Xpp3Dom configuration) { convertExcludes(option, configuration); convertGroups(option, configuration); convertTestFailureIgnore(option, configuration); + convertArgLine(option, configuration); return option; } @@ -68,6 +69,18 @@ private void convertExcludes(ReportOptions option, Xpp3Dom configuration) { option.setExcludedTestClasses(excludes); } + private void convertArgLine(ReportOptions option, Xpp3Dom configuration) { + if (option.getArgLine() != null) { + return; + } + + Xpp3Dom argLine = configuration.getChild("argLine"); + if (argLine != null) { + option.setArgLine(argLine.getValue()); + } + } + + private Predicate filenameToClassFilter(String filename) { return new Glob(filename.replace(".java", "").replace("/", ".")); } diff --git a/pitest-maven/src/test/java/org/pitest/maven/MojoToReportOptionsConverterTest.java b/pitest-maven/src/test/java/org/pitest/maven/MojoToReportOptionsConverterTest.java index 98b3d332a..211895a52 100644 --- a/pitest-maven/src/test/java/org/pitest/maven/MojoToReportOptionsConverterTest.java +++ b/pitest-maven/src/test/java/org/pitest/maven/MojoToReportOptionsConverterTest.java @@ -471,7 +471,6 @@ public void testAutoAddsKotlinSourceDirsWhenPresent() throws IOException { } - private ReportOptions parseConfig(final String xml) { try { final String pom = createPomWithConfiguration(xml); diff --git a/pitest-maven/src/test/java/org/pitest/maven/SurefireConfigConverterTest.java b/pitest-maven/src/test/java/org/pitest/maven/SurefireConfigConverterTest.java index 5ad0f1648..6a10d5b97 100644 --- a/pitest-maven/src/test/java/org/pitest/maven/SurefireConfigConverterTest.java +++ b/pitest-maven/src/test/java/org/pitest/maven/SurefireConfigConverterTest.java @@ -164,6 +164,29 @@ public void shouldConvertTestFailureIgnoreWhenAbsent() throws Exception { assertThat(actual.skipFailingTests()).isFalse(); } + @Test + public void convertsArgline() throws Exception { + this.surefireConfig = makeConfig("-Xmx1024m"); + + ReportOptions actual = this.testee + .update(this.options, this.surefireConfig); + + assertThat(actual.getArgLine()).isEqualTo("-Xmx1024m"); + } + + @Test + public void doesNotConvertArglineWhenAlreadySetInPitestConfig() throws Exception { + this.surefireConfig = makeConfig("-Xmx1024m"); + + this.options.setArgLine("-foo"); + + ReportOptions actual = this.testee + .update(this.options, this.surefireConfig); + + assertThat(actual.getArgLine()).isEqualTo("-foo"); + } + + private Xpp3Dom makeConfig(String s) throws Exception { String xml = "" + s + ""; InputStream stream = new ByteArrayInputStream(xml.getBytes("UTF-8"));