Skip to content

Commit

Permalink
Add UP-TO-DATE tests for changing artifacts
Browse files Browse the repository at this point in the history
This test should cover #528 and show that it is no longer an issue.
  • Loading branch information
clayburn committed May 4, 2022
1 parent 8df229f commit bd499dd
Showing 1 changed file with 70 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,76 @@ class ProtobufJavaPluginTest extends Specification {
gradleVersion << GRADLE_VERSIONS
}
@Unroll
void "test proto generation is not up-to-date on dependency changes [gradle #gradleVersion]"() {
given: "project from testProject"
File projectDir = ProtobufPluginTestHelper.projectBuilder('testProject')
.copyDirs('testProjectBase', 'testProject')
.build()
when: "build is invoked"
BuildResult 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(":build").outcome == TaskOutcome.SUCCESS
when: "protoc artifact is changed and build runs again"
new File(projectDir, "build.gradle")
.append("""
protobuf {
protoc {
artifact = '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
when: "plugin artifact is changed and build runs again"
new File(projectDir, "build.gradle")
.append("""
protobuf {
plugins {
grpc {
artifact = 'io.grpc:protoc-gen-grpc-java:1.0.3'
}
}
}""")
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(":generateGrpcProto").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 bd499dd

Please sign in to comment.