Skip to content

Commit

Permalink
fix: always print message about failure and report location (#285)
Browse files Browse the repository at this point in the history
* feat: this fixes #284 - when suppressing stack trace still print message about where report is

* feat: refs #284 - add unit test to prove report location is still printed even when suppressing stack trace

* feat: refs #284 - removing line that should have been moved to different test

* feat: refs #284 - fixing whitespace
  • Loading branch information
jscancella authored Jun 19, 2020
1 parent 2c7e412 commit fb16d11
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,40 @@ buildDir = 'new-build-dir'
assertTrue(report.isFile())
}

def "prints reports location when stacktrace is suppressed"() {
buildFile << """
spotbugsMain {
showStackTraces = false
reports {
text.enabled = true
}
}
buildDir = 'new-build-dir'
"""
given:
def badCode = new File(rootDir, 'src/main/java/Bar.java')
badCode << '''
|public class Bar {
| public int unreadField = 42; // warning: URF_UNREAD_FIELD
|}
|'''.stripMargin()

when:
def result = GradleRunner.create()
.withProjectDir(rootDir)
.withArguments('spotbugsMain')
.withPluginClasspath()
.buildAndFail()

then:
//issue 284 - information on where the report should still be printed even if suppressing stack traces.
result.output.contains('SpotBugs report can be found in')
}

def "can generate spotbugs.html in configured buildDir"() {
buildFile << """
spotbugsMain {
showStackTraces = false
reports {
html.enabled = true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void execute() {
if (params.getIgnoreFailures().getOrElse(Boolean.FALSE).booleanValue()) {
final boolean showStackTraces =
params.getShowStackTraces().getOrElse(Boolean.TRUE).booleanValue();
log.warn("SpotBugs reported failures", showStackTraces ? e : null);
log.warn("SpotBugs reported failures", showStackTraces ? e : e.getMessage());
} else {
throw e;
}
Expand Down

0 comments on commit fb16d11

Please sign in to comment.