Skip to content

Commit

Permalink
JENKINS-18885 add option to disable output of the TAP comment diagnos…
Browse files Browse the repository at this point in the history
…tics
  • Loading branch information
kinow committed Jul 23, 2013
1 parent 21e7af0 commit 295d37a
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 24 deletions.
Expand Up @@ -40,7 +40,7 @@ public class AbstractTapProjectAction implements Action {
* @see hudson.model.Action#getDisplayName()
*/
public String getDisplayName() {
return "TAP";
return "TAP Extended Test Results";
}

/* (non-Javadoc)
Expand Down
16 changes: 15 additions & 1 deletion src/main/java/org/tap4j/plugin/TapParser.java
Expand Up @@ -59,7 +59,12 @@ public class TapParser {
private PrintStream logger;
private boolean parserErrors;
private boolean hasFailedTests;
private boolean includeCommentDiagnostics;

/**
* @deprecated
*/
@Deprecated
public TapParser(Boolean outputTapToConsole, Boolean enableSubtests, Boolean todoIsFailure, PrintStream logger) {
this.outputTapToConsole = outputTapToConsole;
this.enableSubtests = enableSubtests;
Expand All @@ -68,6 +73,15 @@ public TapParser(Boolean outputTapToConsole, Boolean enableSubtests, Boolean tod
this.parserErrors = false;
this.hasFailedTests = false;
}

public TapParser(Boolean outputTapToConsole, Boolean enableSubtests, Boolean todoIsFailure, Boolean includeCommentDiagnostics, PrintStream logger) {
this.outputTapToConsole = outputTapToConsole;
this.enableSubtests = enableSubtests;
this.todoIsFailure = todoIsFailure;
this.logger = logger;
this.parserErrors = false;
this.includeCommentDiagnostics = false;
}

public boolean hasParserErrors() {
return this.parserErrors;
Expand Down Expand Up @@ -128,7 +142,7 @@ public TapResult parse(FilePath[] results, AbstractBuild<?, ?> build) {
}
}
//final TapResult testResult = new TapResult(UUID.randomUUID().toString(), build, testSets);
final TapResult testResult = new TapResult("TAP Test Results", build, testSets, this.todoIsFailure);
final TapResult testResult = new TapResult("TAP Test Results", build, testSets, this.todoIsFailure, this.includeCommentDiagnostics);
return testResult;
}

Expand Down
17 changes: 14 additions & 3 deletions src/main/java/org/tap4j/plugin/TapPublisher.java
Expand Up @@ -67,6 +67,7 @@ public class TapPublisher extends Recorder implements MatrixAggregatable {
private final Boolean enableSubtests;
private final Boolean discardOldReports;
private final Boolean todoIsFailure;
private final Boolean includeCommentDiagnostics;

@DataBoundConstructor
public TapPublisher(String testResults,
Expand All @@ -75,14 +76,16 @@ public TapPublisher(String testResults,
Boolean outputTapToConsole,
Boolean enableSubtests,
Boolean discardOldReports,
Boolean todoIsFailure) {
Boolean todoIsFailure,
Boolean includeCommentDiagnostics) {
this.testResults = testResults;
this.failIfNoResults = BooleanUtils.toBooleanDefaultIfNull(failIfNoResults, false);
this.failedTestsMarkBuildAsFailure = BooleanUtils.toBooleanDefaultIfNull(failedTestsMarkBuildAsFailure, false);
this.outputTapToConsole = outputTapToConsole;
this.enableSubtests = BooleanUtils.toBooleanDefaultIfNull(enableSubtests, true);
this.discardOldReports = BooleanUtils.toBooleanDefaultIfNull(discardOldReports, false);
this.todoIsFailure = BooleanUtils.toBooleanDefaultIfNull(todoIsFailure, true);
this.includeCommentDiagnostics = BooleanUtils.toBooleanDefaultIfNull(includeCommentDiagnostics, true);
}

public Object readResolve() {
Expand All @@ -93,7 +96,8 @@ public Object readResolve() {
Boolean enableSubtests = BooleanUtils.toBooleanDefaultIfNull(this.getEnableSubtests(), true);
Boolean discardOldReports = BooleanUtils.toBooleanDefaultIfNull(this.getDiscardOldReports(), false);
Boolean todoIsFailure = BooleanUtils.toBooleanDefaultIfNull(this.getTodoIsFailure(), true);
return new TapPublisher(testResults, failIfNoResults, failedTestsMarkBuildAsFailure, outputTapToConsole, enableSubtests, discardOldReports, todoIsFailure);
Boolean includeCommentDiagnostics = BooleanUtils.toBooleanDefaultIfNull(this.getIncludeCommentDiagnostics(), true);
return new TapPublisher(testResults, failIfNoResults, failedTestsMarkBuildAsFailure, outputTapToConsole, enableSubtests, discardOldReports, todoIsFailure, includeCommentDiagnostics);
}

/**
Expand Down Expand Up @@ -143,6 +147,13 @@ public Boolean getTodoIsFailure() {
}

/**
* @return the includeCommentDiagnostics
*/
public Boolean getIncludeCommentDiagnostics() {
return includeCommentDiagnostics;
}

/**
* Gets the directory where the plug-in saves its TAP streams before processing them and
* displaying in the UI.
* <p>
Expand Down Expand Up @@ -258,7 +269,7 @@ private TapResult loadResults(AbstractBuild<?, ?> owner, PrintStream logger) {
try {
results = tapDir.list("**/*.*");

final TapParser parser = new TapParser(getOutputTapToConsole(), getEnableSubtests(), getTodoIsFailure(), logger);
final TapParser parser = new TapParser(getOutputTapToConsole(), getEnableSubtests(), getTodoIsFailure(), getIncludeCommentDiagnostics(), logger);
final TapResult result = parser.parse(results, owner);
result.setOwner(owner);
return result;
Expand Down
23 changes: 23 additions & 0 deletions src/main/java/org/tap4j/plugin/TapResult.java
Expand Up @@ -78,13 +78,15 @@ public class TapResult implements ModelObject, Serializable {
private int total = 0;
private String name;
private Boolean todoIsFailure;
private Boolean includeCommentDiagnostics;

/**
* @deprecated since JENKINS-15401
* @param name
* @param owner
* @param testSets
*/
@Deprecated
public TapResult(String name, AbstractBuild<?, ?> owner,
List<TestSetMap> testSets) {
this.name = name;
Expand All @@ -94,6 +96,10 @@ public TapResult(String name, AbstractBuild<?, ?> owner,
this.todoIsFailure = true;
}

/**
* @deprecated
*/
@Deprecated
public TapResult(String name, AbstractBuild<?, ?> owner,
List<TestSetMap> testSets, Boolean todoIsFailure) {
this.name = name;
Expand All @@ -103,13 +109,30 @@ public TapResult(String name, AbstractBuild<?, ?> owner,
this.todoIsFailure = todoIsFailure;
}

public TapResult(String name, AbstractBuild<?, ?> owner,
List<TestSetMap> testSets, Boolean todoIsFailure, Boolean includeCommentDiagnostics) {
this.name = name;
this.build = owner;
this.testSets = this.filterTestSet(testSets);
this.parseErrorTestSets = this.filterParseErrorTestSets(testSets);
this.todoIsFailure = todoIsFailure;
this.includeCommentDiagnostics= includeCommentDiagnostics;
}

/**
* @return the todoIsFailure
*/
public Boolean getTodoIsFailure() {
return todoIsFailure;
}

/**
* @return the includeCommentDiagnostics
*/
public Boolean getIncludeCommentDiagnostics() {
return (includeCommentDiagnostics == null) ? true : includeCommentDiagnostics;
}

/**
* @param testSets
* Untiltered test sets
Expand Down
41 changes: 23 additions & 18 deletions src/main/resources/org/tap4j/plugin/TapPublisher/config.jelly
Expand Up @@ -3,22 +3,27 @@
<f:entry title="Test results" field="testResults">
<f:textbox />
</f:entry>
<f:entry title="Fail the build if no test results are present">
<f:checkbox name="TapPublisher.failIfNoResults" value="${instance.failIfNoResults}" checked="${instance.failIfNoResults}" />
</f:entry>
<f:entry title="Failed tests mark build as failure">
<f:checkbox name="TapPublisher.failedTestsMarkBuildAsFailure" value="${instance.failedTestsMarkBuildAsFailure}" checked="${instance.failedTestsMarkBuildAsFailure}" />
</f:entry>
<f:entry title="Output TAP to console">
<f:checkbox name="TapPublisher.outputTapToConsole" value="${instance.outputTapToConsole}" checked="${instance.outputTapToConsole}" />
</f:entry>
<f:entry title="Enable subtests">
<f:checkbox name="TapPublisher.enableSubtests" value="${instance.enableSubtests}" checked="${instance.enableSubtests}" />
</f:entry>
<f:entry title="Discard old reports">
<f:checkbox name="TapPublisher.discardOldReports" value="${instance.discardOldReports}" checked="${instance.discardOldReports}" />
</f:entry>
<f:entry title="TODO directive fails a test">
<f:checkbox name="TapPublisher.todoIsFailure" value="${instance.todoIsFailure}" checked="${instance.todoIsFailure}" />
</f:entry>
<f:advanced>
<f:entry title="Fail the build if no test results are present">
<f:checkbox name="TapPublisher.failIfNoResults" value="${instance.failIfNoResults}" checked="${instance.failIfNoResults}" />
</f:entry>
<f:entry title="Failed tests mark build as failure">
<f:checkbox name="TapPublisher.failedTestsMarkBuildAsFailure" value="${instance.failedTestsMarkBuildAsFailure}" checked="${instance.failedTestsMarkBuildAsFailure}" />
</f:entry>
<f:entry title="Output TAP to console">
<f:checkbox name="TapPublisher.outputTapToConsole" value="${instance.outputTapToConsole}" checked="${instance.outputTapToConsole}" />
</f:entry>
<f:entry title="Enable subtests">
<f:checkbox name="TapPublisher.enableSubtests" value="${instance.enableSubtests}" checked="${instance.enableSubtests}" />
</f:entry>
<f:entry title="Discard old reports">
<f:checkbox name="TapPublisher.discardOldReports" value="${instance.discardOldReports}" checked="${instance.discardOldReports}" />
</f:entry>
<f:entry title="TODO directive fails a test">
<f:checkbox name="TapPublisher.todoIsFailure" value="${instance.todoIsFailure}" checked="${instance.todoIsFailure}" />
</f:entry>
<f:entry title="Include comment diagnostics (#) in the results table">
<f:checkbox name="TapPublisher.includeCommentDiagnostics" value="${instance.includeCommentDiagnostics}" checked="${instance.includeCommentDiagnostics}" />
</f:entry>
</f:advanced>
</j:jelly>
2 changes: 1 addition & 1 deletion src/main/resources/org/tap4j/plugin/tags/line.jelly
Expand Up @@ -27,7 +27,7 @@
<tap:directive directive="" />
</tr>
</j:when>
<j:when test="${it.isComment( tapLine )}">
<j:when test="${it.isComment( tapLine ) and it.includeCommentDiagnostics}">
<tr>
<td></td>
<td colspan='3'>
Expand Down
Expand Up @@ -44,6 +44,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher arg1,
true,
true,
true,
true,
true);
project.getPublishersList().add(publisher);
project.save();
Expand Down
Expand Up @@ -51,6 +51,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher arg1,
true,
true,
true,
true,
true);
project.getPublishersList().add(publisher);
project.save();
Expand Down

0 comments on commit 295d37a

Please sign in to comment.