Skip to content

Commit

Permalink
parse surefire argline
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry Coles committed Jan 19, 2024
1 parent 3cd8d17 commit 28045a0
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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<String> filenameToClassFilter(String filename) {
return new Glob(filename.replace(".java", "").replace("/", "."));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,6 @@ public void testAutoAddsKotlinSourceDirsWhenPresent() throws IOException {

}


private ReportOptions parseConfig(final String xml) {
try {
final String pom = createPomWithConfiguration(xml);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,29 @@ public void shouldConvertTestFailureIgnoreWhenAbsent() throws Exception {
assertThat(actual.skipFailingTests()).isFalse();
}

@Test
public void convertsArgline() throws Exception {
this.surefireConfig = makeConfig("<argLine>-Xmx1024m</argLine>");

ReportOptions actual = this.testee
.update(this.options, this.surefireConfig);

assertThat(actual.getArgLine()).isEqualTo("-Xmx1024m");
}

@Test
public void doesNotConvertArglineWhenAlreadySetInPitestConfig() throws Exception {
this.surefireConfig = makeConfig("<argLine>-Xmx1024m</argLine>");

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 = "<configuration>" + s + "</configuration>";
InputStream stream = new ByteArrayInputStream(xml.getBytes("UTF-8"));
Expand Down

0 comments on commit 28045a0

Please sign in to comment.