Skip to content
Permalink
Browse files

[FIXED JENKINS-15322] Fixed bug after a new release in tap4j. The par…

…ser was treating unknown content as subtests
  • Loading branch information...
kinow committed Nov 25, 2012
1 parent 490d52e commit ae773491476f022cf11afbe7c820b76b36bbb646
@@ -152,7 +152,7 @@
<dependency>
<groupId>org.tap4j</groupId>
<artifactId>tap4j</artifactId>
<version>3.1</version>
<version>3.3</version>
</dependency>
</dependencies>

@@ -52,13 +52,15 @@
private static final Logger log = Logger.getLogger(TapParser.class
.getName());
private Boolean outputTapToConsole;
private Boolean enableSubtests;
/** Build's logger to print logs as part of build's console output */
private PrintStream logger;
private boolean parserErrors;
private boolean hasFailedTests;

public TapParser(Boolean outputTapToConsole, PrintStream logger) {
public TapParser(Boolean outputTapToConsole, Boolean enableSubtests, PrintStream logger) {
this.outputTapToConsole = outputTapToConsole;
this.enableSubtests = enableSubtests;
this.logger = logger;
this.parserErrors = false;
this.hasFailedTests = false;
@@ -91,8 +93,13 @@ public TapResult parse(FilePath[] results, AbstractBuild<?, ?> build) {
try {
log("Parsing TAP test result [" + tapFile + "].");

final TestSet testSet = new Tap13YamlParser()
.parseFile(tapFile);
final Tap13YamlParser parser;
if(enableSubtests != null) {
parser = new Tap13YamlParser(enableSubtests);
} else {
parser = new Tap13YamlParser();
}
final TestSet testSet = parser.parseFile(tapFile);

if (testSet.containsNotOk() || testSet.containsBailOut()) {
this.hasFailedTests = Boolean.TRUE;
@@ -61,31 +61,47 @@
private final Boolean failIfNoResults;
private final Boolean failedTestsMarkBuildAsFailure;
private final Boolean outputTapToConsole;
private final Boolean enableSubtests;
private final Boolean discardOldReports;

@DataBoundConstructor
public TapPublisher(String testResults,
Boolean failIfNoResults,
Boolean failedTestsMarkBuildAsFailure,
Boolean outputTapToConsole) {
Boolean outputTapToConsole,
Boolean enableSubtests,
Boolean discardOldReports) {
this.testResults = testResults;
if(failIfNoResults == null) {
this.failIfNoResults = Boolean.FALSE;
} else {
this.failIfNoResults = failIfNoResults;
}
if (failedTestsMarkBuildAsFailure == null) {
if(failedTestsMarkBuildAsFailure == null) {
this.failedTestsMarkBuildAsFailure = Boolean.FALSE;
} else {
this.failedTestsMarkBuildAsFailure = failedTestsMarkBuildAsFailure;
}
this.outputTapToConsole = outputTapToConsole;
if(enableSubtests == null) {
this.enableSubtests = Boolean.TRUE;
} else {
this.enableSubtests = enableSubtests;
}
if(discardOldReports == null) {
this.discardOldReports = Boolean.FALSE;
} else {
this.discardOldReports = discardOldReports;
}
}

public Object readResolve() {
String testResults = this.getTestResults();
Boolean failIfNoResults = this.getFailIfNoResults();
Boolean failedTestsMarkBuildAsFailure = this.getFailedTestsMarkBuildAsFailure();
Boolean outputTapToConsole = this.getOutputTapToConsole();
Boolean enableSubtests = this.getEnableSubtests();
Boolean discardOldReports = this.getDiscardOldReports();
if (failedTestsMarkBuildAsFailure == null) {
failedTestsMarkBuildAsFailure = Boolean.FALSE;
}
@@ -95,7 +111,14 @@ public Object readResolve() {
if (outputTapToConsole == null) {
outputTapToConsole = Boolean.FALSE;
}
return new TapPublisher(testResults, failIfNoResults, failedTestsMarkBuildAsFailure, outputTapToConsole);
if(enableSubtests == null) {
enableSubtests = Boolean.TRUE;
}
if(discardOldReports == null) {
discardOldReports = Boolean.FALSE;
}

return new TapPublisher(testResults, failIfNoResults, failedTestsMarkBuildAsFailure, outputTapToConsole, enableSubtests, discardOldReports);
}

/**
@@ -122,6 +145,20 @@ public Boolean getFailedTestsMarkBuildAsFailure() {
public Boolean getOutputTapToConsole() {
return outputTapToConsole;
}

/**
* @return the enableSubtests
*/
public Boolean getEnableSubtests() {
return enableSubtests;
}

/**
* @return the discardOldReports
*/
public Boolean getDiscardOldReports() {
return discardOldReports;
}

/*
* (non-Javadoc)
@@ -169,7 +206,9 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
/*
* filter out the reports based on timestamps. See JENKINS-12187
*/
//reports = checkReports(build, reports, logger);
if(this.getDiscardOldReports()) {
reports = checkReports(build, reports, logger);
}

boolean filesSaved = saveReports(getTapReportDirectory(build), reports,logger);
if (!filesSaved) {
@@ -236,7 +275,7 @@ private TapResult loadResults(AbstractBuild<?, ?> owner,
return tr;
}

TapParser parser = new TapParser(this.outputTapToConsole, logger);
TapParser parser = new TapParser(this.outputTapToConsole, this.enableSubtests, logger);
TapResult result = parser.parse(results, owner);
result.setOwner(owner);
return result;
@@ -36,7 +36,6 @@
import org.tap4j.model.Directive;
import org.tap4j.model.TestSet;
import org.tap4j.plugin.TapResult;
import org.tap4j.producer.TapProducer;
import org.tap4j.util.DirectiveValues;
import org.tap4j.util.StatusValues;

@@ -12,4 +12,10 @@
<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>
</j:jelly>

0 comments on commit ae77349

Please sign in to comment.
You can’t perform that action at this time.