Skip to content
Permalink
Browse files
[FIXED JENKINS-17804] Add option to show only failures
  • Loading branch information
kinow committed Oct 9, 2015
1 parent 4343691 commit eb95aac4f93273e8d821d818500be9b69af7fa07
@@ -73,8 +73,9 @@ public class TapPublisher extends Recorder implements MatrixAggregatable {
private final Boolean validateNumberOfTests;
private final Boolean planRequired;
private final Boolean verbose;
private final Boolean showOnlyFailures;

@DataBoundConstructor
@Deprecated
public TapPublisher(String testResults,
Boolean failIfNoResults,
Boolean failedTestsMarkBuildAsFailure,
@@ -86,6 +87,25 @@ public TapPublisher(String testResults,
Boolean validateNumberOfTests,
Boolean planRequired,
Boolean verbose) {
this(testResults, failIfNoResults, failedTestsMarkBuildAsFailure,
outputTapToConsole, enableSubtests, discardOldReports, todoIsFailure,
includeCommentDiagnostics, validateNumberOfTests, planRequired, verbose,
Boolean.FALSE);
}

@DataBoundConstructor
public TapPublisher(String testResults,
Boolean failIfNoResults,
Boolean failedTestsMarkBuildAsFailure,
Boolean outputTapToConsole,
Boolean enableSubtests,
Boolean discardOldReports,
Boolean todoIsFailure,
Boolean includeCommentDiagnostics,
Boolean validateNumberOfTests,
Boolean planRequired,
Boolean verbose,
Boolean showOnlyFailures) {
this.testResults = testResults;
this.failIfNoResults = BooleanUtils.toBooleanDefaultIfNull(failIfNoResults, false);
this.failedTestsMarkBuildAsFailure = BooleanUtils.toBooleanDefaultIfNull(failedTestsMarkBuildAsFailure, false);
@@ -97,6 +117,7 @@ public TapPublisher(String testResults,
this.validateNumberOfTests = BooleanUtils.toBooleanDefaultIfNull(validateNumberOfTests, false);
this.planRequired = BooleanUtils.toBooleanDefaultIfNull(planRequired, true); // true is the old behaviour
this.verbose = BooleanUtils.toBooleanDefaultIfNull(verbose, true);
this.showOnlyFailures = BooleanUtils.toBooleanDefaultIfNull(showOnlyFailures, false);
}

public Object readResolve() {
@@ -111,7 +132,12 @@ public Object readResolve() {
Boolean validateNumberOfTests = BooleanUtils.toBooleanDefaultIfNull(this.getValidateNumberOfTests(), false);
Boolean planRequired = BooleanUtils.toBooleanDefaultIfNull(this.getPlanRequired(), true);
Boolean verbose = BooleanUtils.toBooleanDefaultIfNull(this.getVerbose(), true);
return new TapPublisher(testResults, failIfNoResults, failedTestsMarkBuildAsFailure, outputTapToConsole, enableSubtests, discardOldReports, todoIsFailure, includeCommentDiagnostics, validateNumberOfTests, planRequired, verbose);
Boolean showOnlyFailures = BooleanUtils.toBooleanDefaultIfNull(this.getShowOnlyFailures(), false);
return new TapPublisher(testResults, failIfNoResults, failedTestsMarkBuildAsFailure, outputTapToConsole, enableSubtests, discardOldReports, todoIsFailure, includeCommentDiagnostics, validateNumberOfTests, planRequired, verbose, showOnlyFailures);
}

public Boolean getShowOnlyFailures() {
return this.showOnlyFailures;
}

/**
@@ -249,6 +275,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
TapResult testResult = null;
try {
testResult = loadResults(build, logger);
testResult.setShowOnlyFailures(this.getShowOnlyFailures());
testResult.tally();
} catch (Throwable t) {
/*
@@ -34,6 +34,7 @@
import javax.servlet.ServletOutputStream;

import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang.BooleanUtils;
import org.apache.commons.lang.StringUtils;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
@@ -81,6 +82,7 @@ public class TapResult implements ModelObject, Serializable {
private Boolean todoIsFailure;
private Boolean includeCommentDiagnostics;
private Boolean validateNumberOfTests;
private Boolean showOnlyFailures = Boolean.FALSE;

public TapResult(String name, AbstractBuild<?, ?> owner,
List<TestSetMap> testSets, Boolean todoIsFailure, Boolean includeCommentDiagnostics ,
@@ -94,6 +96,14 @@ public TapResult(String name, AbstractBuild<?, ?> owner,
this.validateNumberOfTests = validateNumberOfTests;
}

public Boolean getShowOnlyFailures() {
return BooleanUtils.toBooleanDefaultIfNull(showOnlyFailures, Boolean.FALSE);
}

public void setShowOnlyFailures(Boolean showOnlyFailures) {
this.showOnlyFailures = showOnlyFailures;
}

/**
* @return the todoIsFailure
*/
@@ -34,5 +34,8 @@
<f:entry title="Is TAP plan required?">
<f:checkbox name="TapPublisher.planRequired" value="${instance.planRequired}" checked="${instance.planRequired}" default="true" />
</f:entry>
<f:entry title="Show only failures">
<f:checkbox name="TapPublisher.showOnlyFailures" value="${instance.showOnlyFailures}" checked="${instance.showOnlyFailures}" default="false" />
</f:entry>
</f:advanced>
</j:jelly>
@@ -24,7 +24,11 @@
<td width='5%'>${it.testSets.size()} files</td>
<td>${it.getTotal()} tests, ${it.passed} ok, ${it.failed} not ok, ${it.skipped} skipped, ${it.bailOuts} Bail Out!</td>
</tr>
</table>
</table>

<j:if test="${it.showOnlyFailures}">
<p><strong>Note:</strong> Displaying only failures</p>
</j:if>

<j:forEach var="map" items="${it.testSets}">
<j:choose>
@@ -43,10 +47,8 @@
<th>Directive</th>
</tr>
<j:forEach var="tapLine" items="${map.testSet.tapLines}">

<!-- TAP Test Result information -->
<tap:line tapLine="${tapLine}" tapFile="${map.fileName}" />

<tap:line tapLine="${tapLine}" tapFile="${map.fileName}" showOnlyFailures="${it.showOnlyFailures}" />
</j:forEach>
</table>
<br />
@@ -7,18 +7,30 @@
<j:when test="${attrs.tapLine != null}">
<j:set var="tapLine" value="${attrs.tapLine}" />
<j:set var="tapFile" value="${attrs.tapFile}" />
<j:set var="showOnlyFailures" value="${attrs.showOnlyFailures}" />
<j:choose>
<j:when test="${it.isTestResult( tapLine )}">
<tr>
<tap:status testResult="${tapLine}" />
<td width="5%" class="center">${tapLine.testNumber}</td>
<td width="65%">${tapLine.description}</td>
<tap:directive directive="${tapLine.directive}" />
</tr>
<!-- Comments diagnostics -->
<!-- tap:comments diagnostic="${tapLine.comments}" /-->
<!-- YAML Diagnostics -->
<tap:yaml diagnostic="${tapLine.diagnostic}" tapFile="${tapFile}" />
<j:set var="hide" value="false" />
<j:if test="${showOnlyFailures}">
<j:if test="${tapLine != null}">
<j:set var="testResult" value="${tapLine}" />
<j:if test="${testResult.status.toString() == 'ok'}">
<j:set var="hide" value="true" />
</j:if>
</j:if>
</j:if>
<j:if test="${hide == 'false'}">
<tr>
<tap:status testResult="${tapLine}" />
<td width="5%" class="center">${tapLine.testNumber}</td>
<td width="65%">${tapLine.description}</td>
<tap:directive directive="${tapLine.directive}" />
</tr>
<!-- Comments diagnostics -->
<!-- tap:comments diagnostic="${tapLine.comments}" /-->
<!-- YAML Diagnostics -->
<tap:yaml diagnostic="${tapLine.diagnostic}" tapFile="${tapFile}" />
</j:if>
</j:when>
<j:when test="${it.isBailOut( tapLine )}">
<tr>
@@ -8,7 +8,7 @@
<j:set var="diagnostic" value="${attrs.diagnostic}" />
<j:set var="tapFile" value="${attrs.tapFile}" />

${ it.createDiagnosticTable( tapFile, diagnostic ) }
<j:out value="${ it.createDiagnosticTable( tapFile, diagnostic ) }"/>

<!--tr>
<table width="100%" class="yaml">

0 comments on commit eb95aac

Please sign in to comment.