Skip to content
Permalink
Browse files
Merge pull request #7 from sschuberth/master
[FIXED JENKINS-22047] Add option to reduce noise in logs
  • Loading branch information
kinow committed Jul 25, 2014
2 parents 65b57b2 + 82167d2 commit 239c532ed290149d3b0fd3d3f72e67e761400683
@@ -49,8 +49,7 @@
public class TapParser {

/** Prints the logs to the web server's console / log files */
private static final Logger log = Logger.getLogger(TapParser.class
.getName());
private static final Logger log = Logger.getLogger(TapParser.class.getName());
private final Boolean outputTapToConsole;
private final Boolean enableSubtests;
private final Boolean todoIsFailure;
@@ -60,21 +59,23 @@ public class TapParser {
private final Boolean includeCommentDiagnostics;
private final Boolean validateNumberOfTests;
private final Boolean planRequired;
private final Boolean verbose;

private boolean hasFailedTests;
private boolean parserErrors;

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

public Boolean hasParserErrors() {
@@ -112,6 +113,10 @@ public Boolean getEnableSubtests() {
public boolean hasFailedTests() {
return this.hasFailedTests;
}

public Boolean getVerbose() {
return verbose;
}

public TapResult parse(FilePath[] results, AbstractBuild<?, ?> build) {
this.parserErrors = Boolean.FALSE;
@@ -163,7 +168,7 @@ public TapResult parse(FilePath[] results, AbstractBuild<?, ?> build) {
}

private void log(String str) {
if (logger != null) {
if (verbose && logger != null) {
logger.println(str);
} else {
log.fine(str);
@@ -74,6 +74,7 @@ public class TapPublisher extends Recorder implements MatrixAggregatable {
private final Boolean includeCommentDiagnostics;
private final Boolean validateNumberOfTests;
private final Boolean planRequired;
private final Boolean verbose;

@DataBoundConstructor
public TapPublisher(String testResults,
@@ -85,7 +86,8 @@ public TapPublisher(String testResults,
Boolean todoIsFailure,
Boolean includeCommentDiagnostics,
Boolean validateNumberOfTests,
Boolean planRequired) {
Boolean planRequired,
Boolean verbose) {
this.testResults = testResults;
this.failIfNoResults = BooleanUtils.toBooleanDefaultIfNull(failIfNoResults, false);
this.failedTestsMarkBuildAsFailure = BooleanUtils.toBooleanDefaultIfNull(failedTestsMarkBuildAsFailure, false);
@@ -95,7 +97,8 @@ public TapPublisher(String testResults,
this.todoIsFailure = BooleanUtils.toBooleanDefaultIfNull(todoIsFailure, true);
this.includeCommentDiagnostics = BooleanUtils.toBooleanDefaultIfNull(includeCommentDiagnostics, true);
this.validateNumberOfTests = BooleanUtils.toBooleanDefaultIfNull(validateNumberOfTests, false);
this.planRequired = BooleanUtils.toBooleanDefaultIfNull(planRequired, Boolean.TRUE); // true is the old behaviour
this.planRequired = BooleanUtils.toBooleanDefaultIfNull(planRequired, true); // true is the old behaviour
this.verbose = BooleanUtils.toBooleanDefaultIfNull(verbose, true);
}

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

/**
@@ -172,6 +176,10 @@ public Boolean getValidateNumberOfTests() {
public Boolean getPlanRequired() {
return planRequired;
}

public Boolean getVerbose() {
return verbose;
}

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

final TapParser parser = new TapParser(getOutputTapToConsole(), getEnableSubtests(), getTodoIsFailure(), getIncludeCommentDiagnostics(), getValidateNumberOfTests(), getPlanRequired(), logger);
final TapParser parser = new TapParser(getOutputTapToConsole(), getEnableSubtests(), getTodoIsFailure(), getIncludeCommentDiagnostics(), getValidateNumberOfTests(), getPlanRequired(), getVerbose(), logger);
final TapResult result = parser.parse(results, owner);
result.setOwner(owner);
return result;
@@ -3,6 +3,9 @@
<f:entry title="Test results" field="testResults">
<f:textbox />
</f:entry>
<f:entry title="Verbose (if checked will print a message for each TAP stream file)">
<f:checkbox name="TapPublisher.verbose" value="${instance.verbose}" checked="${instance.verbose}" default="true" />
</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}" />
@@ -47,7 +47,8 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher arg1,
true,
true,
true,
false);
false,
true);
project.getPublishersList().add(publisher);
project.save();
FreeStyleBuild build = (FreeStyleBuild) project.scheduleBuild2(0).get();
@@ -54,7 +54,8 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher arg1,
true,
true,
true,
false);
false,
true);
project.getPublishersList().add(publisher);
project.save();
FreeStyleBuild build = (FreeStyleBuild) project.scheduleBuild2(0).get();

0 comments on commit 239c532

Please sign in to comment.