Skip to content

Commit

Permalink
test: reproduce the problem reported as #914
Browse files Browse the repository at this point in the history
Signed-off-by: Kengo TODA <[email protected]>
  • Loading branch information
KengoTODA committed Aug 15, 2023
1 parent 9c4ddff commit a1e53ec
Showing 1 changed file with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,50 @@ class CacheabilityFunctionalTest extends Specification {
result.task(":spotbugsMain").outcome == TaskOutcome.UP_TO_DATE
}

/**
* @see <a href="https://github.com/spotbugs/spotbugs-gradle-plugin/issues/914">GitHub Issues</a>
*/
def 'spotbugsMain is cacheable even if a stylesheet is set as String for the HTML report'() {
given:
def buildDir = Files.createTempDirectory(null).toFile()
def version = System.getProperty('snom.test.functional.gradle', GradleVersion.current().version)
def buildFile = new File(buildDir, "build.gradle")

initializeBuildFile(buildDir)
buildFile.delete()
new File(buildDir, "build.gradle.kts") << """
|import com.github.spotbugs.snom.SpotBugsTask
|plugins {
| `java`
| id("com.github.spotbugs")
|}
|version = "1.0"
|repositories {
| mavenCentral()
|}
|tasks.withType<SpotBugsTask>().configureEach {
| reports {
| create("html") {
| setStylesheet("fancy-hist.xsl")
| }
| }
|}
|""".stripMargin()

when:
def result = GradleRunner.create()
.withProjectDir(buildDir)
.withArguments(':spotbugsMain', '--configuration-cache')
.withPluginClasspath()
.withGradleVersion(version)
.forwardOutput()
.build()

then:
!result.output.contains("Configuration cache problems found in this build")
result.output.contains("Configuration cache entry stored.")
}

private static String getHashKeyLine(BuildResult result) {
return result.output.find('Build cache key for task \':spotbugsMain\' is .*')
}
Expand Down

0 comments on commit a1e53ec

Please sign in to comment.