Skip to content

Commit

Permalink
hide arcmutate link when installed
Browse files Browse the repository at this point in the history
  • Loading branch information
hcoles committed Apr 8, 2024
1 parent b10626d commit e52d86c
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ private MutationResultListener createResultListener(SourceLocator sourceLocator,
mutatorNames,
partialCoverage,
Collections.emptyList(),
true,
sourceLocator);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ public class ReportOptions {
private Charset inputEncoding;
private Charset outputEncoding;

private boolean arcmutateMissing = true;

// currently used only via maven
private Map<String,String> environmentVariables = new HashMap<>();

Expand Down Expand Up @@ -666,6 +668,14 @@ public Map<String,String> getEnvironmentVariables() {
return environmentVariables;
}

public boolean isArcmutateMissing() {
return arcmutateMissing;
}

public void setArcmutateMissing(boolean arcmutateMissing) {
this.arcmutateMissing = arcmutateMissing;
}

@Override
public String toString() {
return new StringJoiner(", ", ReportOptions.class.getSimpleName() + "[", "]")
Expand Down Expand Up @@ -714,8 +724,8 @@ public String toString() {
.add("inputEncoding=" + inputEncoding)
.add("outputEncoding=" + outputEncoding)
.add("reportCoverage=" + reportCoverage)
.add("arcmutateMissing=" + arcmutateMissing)
.toString();
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,8 @@ private void printStats(CombinedStatistics combinedStatistics) {

if (!combinedStatistics.getIssues().isEmpty()) {
ps.println();
ps.println("!! The following issues were detected during the run !!");
combinedStatistics.getIssues().forEach(ps::println);
ps.println("Build messages:- ");
combinedStatistics.getIssues().forEach(m -> ps.println("* " + m));
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.pitest.mutationtest.verify;

import java.util.Objects;
import java.util.Optional;

public final class BuildMessage implements Comparable<BuildMessage> {
private final String text;
Expand Down Expand Up @@ -31,7 +32,8 @@ public int priority() {

@Override
public String toString() {
return text + " (" + url + ")";
return text + Optional.ofNullable(url)
.map( u -> " (" + u + ")").orElse("");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,16 @@ public void sortsZeroPriorityFirst() {
Collections.sort(l);
assertThat(l).containsExactly(b,c,a);
}

@Test
public void includesURLInToStringWhenPresent() {
BuildMessage underTest = new BuildMessage("text", "https://pitest.org", 0);
assertThat(underTest.toString()).isEqualTo("text (https://pitest.org)");
}

@Test
public void doesNotIncludeURLInToStringWhenNull() {
BuildMessage underTest = new BuildMessage("text", null, 0);
assertThat(underTest.toString()).isEqualTo("text");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public MutationResultListener getListener(Properties props,
ListenerArguments args) {
return new MutationHtmlReportListener(args.data().getOutputEncoding(), args.getCoverage(),
args.getOutputStrategy(), args.getEngine().getMutatorNames(), args.data().shouldReportCoverage(),
args.issues(), args.getLocator());
args.issues(), args.data().isArcmutateMissing(), args.getLocator());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,15 @@ public class MutationHtmlReportListener implements MutationResultListener {

private final List<BuildMessage> messages;

private final boolean arcmutateMissing;

public MutationHtmlReportListener(Charset outputCharset,
ReportCoverage coverage,
ResultOutputStrategy outputStrategy,
Collection<String> mutatorNames,
boolean reportCoverage,
List<BuildMessage> messages,
boolean arcmutateMissing,
SourceLocator... locators) {
this.outputCharset = outputCharset;
this.coverage = coverage;
Expand All @@ -76,6 +79,7 @@ public MutationHtmlReportListener(Charset outputCharset,
this.css = loadCss();
this.reportCoverage = reportCoverage;
this.messages = messages;
this.arcmutateMissing = arcmutateMissing;
}

private String loadCss() {
Expand Down Expand Up @@ -227,6 +231,7 @@ private void createIndexPages() {
st.setAttribute("outputCharset", this.outputCharset);
st.setAttribute("showCoverage", this.reportCoverage);
st.setAttribute("messages", wrap(this.messages));
st.setAttribute("arcmutateMissing", arcmutateMissing);
try {
writer.write(st.toString());
writer.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ $errors : { error |

<ul>
$messages:{ message |
<li><a href="$message.url$">$message.text$</a>
$if(message.url)$ <li><a href="$message.url$">$message.text$</a>
$else$ <li>$message.text$
$endif$
}$
</ul>

Expand All @@ -80,7 +82,8 @@ Report generated by <a href='https://pitest.org'>PIT</a> ${project.version}
<br/>
<br/>

Enhanced functionality available at <a href='https://www.arcmutate.com/'>arcmutate.com</a>
$if(arcmutateMissing)$ Enhanced functionality available at <a href='https://www.arcmutate.com/'>arcmutate.com</a>
$endif$

</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void setUp() {
this.classInfo);

this.testee = new MutationHtmlReportListener(StandardCharsets.UTF_8, this.coverageDb,
this.outputStrategy, Collections.<String>emptyList(), true, Collections.emptyList(), this.sourceLocator);
this.outputStrategy, Collections.<String>emptyList(), true, Collections.emptyList(), true, this.sourceLocator);
}

@Test
Expand Down

0 comments on commit e52d86c

Please sign in to comment.