Skip to content

Commit

Permalink
Add UP-TO-DATE tests for changing paths
Browse files Browse the repository at this point in the history
This test should cover google#557.
  • Loading branch information
clayburn committed May 4, 2022
1 parent a92e8eb commit 53bba1f
Showing 1 changed file with 55 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,61 @@ class ProtobufJavaPluginTest extends Specification {
gradleVersion << GRADLE_VERSIONS
}
@Unroll
void "test proto generation is not up-to-date on path changes [gradle #gradleVersion]"() {
given: "project from testProject"
File projectDir = ProtobufPluginTestHelper.projectBuilder('testProject')
.copyDirs('testProjectBase', 'testProject')
.build()
when: "protoc path is set and build is invoked"
def buildGradleFile = new File(projectDir, "build.gradle")
buildGradleFile.append("""
configurations {
protoc
}

dependencies {
protoc "com.google.protobuf:protoc:3.0.0:\$project.osdetector.classifier@exe"
}

protobuf {
protoc {
path = "\$configurations.protoc.singleFile"
}
}""")
def result = GradleRunner.create()
.withProjectDir(projectDir)
.withArguments('build', '--stacktrace')
.withPluginClasspath()
.withGradleVersion(gradleVersion)
.forwardStdOutput(new OutputStreamWriter(System.out))
.forwardStdError(new OutputStreamWriter(System.err))
.withDebug(true)
.build()
then: "it succeeds"
result.task(":generateProto").outcome == TaskOutcome.SUCCESS
when: "protoc path is changed and build runs again"
buildGradleFile.text = buildGradleFile.text.replace("com.google.protobuf:protoc:3.0.0", "com.google.protobuf:protoc:3.0.2")
result = GradleRunner.create()
.withProjectDir(projectDir)
.withArguments('build', '--stacktrace')
.withPluginClasspath()
.withGradleVersion(gradleVersion)
.forwardStdOutput(new OutputStreamWriter(System.out))
.forwardStdError(new OutputStreamWriter(System.err))
.withDebug(true)
.build()
then: "generateProto is not UP_TO_DATE"
result.task(":generateProto").outcome == TaskOutcome.SUCCESS
where:
gradleVersion << GRADLE_VERSIONS
}
@Unroll
void "test proto extraction is up-to-date for testProject when changing java sources [gradle #gradleVersion]"() {
given: "project from testProject"
Expand Down

0 comments on commit 53bba1f

Please sign in to comment.