-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add spotbugsShowStackTraces option to change default for spotbug's sh…
…owStackTraces option to false. required to avoid stacktrace in logs in non-strict mode
- Loading branch information
Showing
4 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
...est/groovy/ru/vyarus/gradle/plugin/quality/tools/spotbugs/ShowStackTraceOptionTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
package ru.vyarus.gradle.plugin.quality.tools.spotbugs | ||
|
||
import org.gradle.testkit.runner.BuildResult | ||
import org.gradle.testkit.runner.TaskOutcome | ||
import ru.vyarus.gradle.plugin.quality.AbstractKitTest | ||
|
||
/** | ||
* @author Vyacheslav Rusakov | ||
* @since 09.11.2021 | ||
*/ | ||
class ShowStackTraceOptionTest extends AbstractKitTest { | ||
|
||
def "Check default behavior"() { | ||
setup: | ||
build(""" | ||
plugins { | ||
id 'groovy' | ||
id 'ru.vyarus.quality' | ||
} | ||
quality { | ||
checkstyle false | ||
pmd false | ||
strict false | ||
} | ||
afterEvaluate { | ||
tasks.withType(com.github.spotbugs.snom.SpotBugsTask).configureEach { | ||
classes = classes.filter { | ||
!it.path.endsWith('Sample2.class') | ||
} | ||
} | ||
} | ||
repositories { | ||
mavenCentral() //required for testKit run | ||
} | ||
dependencies { | ||
implementation localGroovy() | ||
} | ||
""") | ||
|
||
fileFromClasspath('src/main/java/sample/Sample.java', '/ru/vyarus/gradle/plugin/quality/java/sample/Sample.java') | ||
fileFromClasspath('src/main/java/sample/Sample2.java', '/ru/vyarus/gradle/plugin/quality/java/sample/Sample2.java') | ||
|
||
when: "run check task with java and groovy sources" | ||
BuildResult result = run('check') | ||
|
||
then: "spotbugs detect violations, but don't print stack trace" | ||
result.task(":check").outcome == TaskOutcome.SUCCESS | ||
def output = result.output | ||
output.contains("1 (0 / 1 / 0) SpotBugs violations were found in 1 files") | ||
!output.contains("org.gradle.api.GradleException: 1 SpotBugs violations were found. See the report at:") | ||
} | ||
|
||
def "Check original spotbugs behavior"() { | ||
setup: | ||
build(""" | ||
plugins { | ||
id 'groovy' | ||
id 'ru.vyarus.quality' | ||
} | ||
quality { | ||
spotbugsShowStackTraces true | ||
checkstyle false | ||
pmd false | ||
strict false | ||
} | ||
afterEvaluate { | ||
tasks.withType(com.github.spotbugs.snom.SpotBugsTask).configureEach { | ||
classes = classes.filter { | ||
!it.path.endsWith('Sample2.class') | ||
} | ||
} | ||
} | ||
repositories { | ||
mavenCentral() //required for testKit run | ||
} | ||
dependencies { | ||
implementation localGroovy() | ||
} | ||
""") | ||
|
||
fileFromClasspath('src/main/java/sample/Sample.java', '/ru/vyarus/gradle/plugin/quality/java/sample/Sample.java') | ||
fileFromClasspath('src/main/java/sample/Sample2.java', '/ru/vyarus/gradle/plugin/quality/java/sample/Sample2.java') | ||
|
||
when: "run check task with java and groovy sources" | ||
BuildResult result = run('check') | ||
|
||
then: "spotbugs detect violations and print stack trace" | ||
result.task(":check").outcome == TaskOutcome.SUCCESS | ||
def output = result.output | ||
output.contains "org.gradle.api.GradleException: 1 SpotBugs violations were found. See the report at:" | ||
} | ||
} |