Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parse surefire argline #1289

Merged
merged 1 commit into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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