Skip to content

Commit

Permalink
Add failing test for CadixDev#33
Browse files Browse the repository at this point in the history
  • Loading branch information
joschi committed Jul 16, 2021
1 parent 6e73b6b commit 7c4583d
Showing 1 changed file with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,57 @@ class LicenserPluginFunctionalTest extends Specification {
where:
[gradleVersion, _, extraArgs] << testMatrix
}
@Unroll
def "Plugin tasks should work twice with configuration cache enabled (Gradle #gradleVersion)"() {
given:
def projectDir = temporaryFolder.newFolder()
def sourceDir = projectDir.toPath().resolve(Paths.get("src", "main", "java", "com", "example")).toFile()
sourceDir.mkdirs()
new File(projectDir, "LICENSE") << "Copyright header"
new File(projectDir, "settings.gradle") << ""
new File(projectDir, "build.gradle") << """
plugins {
id('java')
id('org.cadixdev.licenser')
}
""".stripIndent().trim()
def sourceFileContent = """\
/*
* My header
*/

package com.example;

class MyClass {}
""".stripIndent()
def sourceFile = new File(sourceDir, "MyClass.java") << sourceFileContent
when:
def runner = runner(projectDir, gradleVersion, extraArgs + "checkLicenses")
runner.debug = true
def result = runner.build()
then:
result.task(":checkLicenses").outcome == TaskOutcome.SUCCESS
sourceFile.text == """\
/*
* Copyright header
*/

package com.example;

class MyClass {}
""".stripIndent()
when:
def secondResult = runner.build()
then:
secondResult.task(":checkLicenses").outcome == TaskOutcome.UP_TO_DATE
where:
[gradleVersion, _, extraArgs] << configurationCacheTestMatrix
}
}

0 comments on commit 7c4583d

Please sign in to comment.