Skip to content

Commit

Permalink
Add test for configuration cache bug
Browse files Browse the repository at this point in the history
This is a test for the scenario in #2837
which has since been fixed already.
  • Loading branch information
staktrace committed Apr 4, 2024
1 parent b5bf223 commit f7ad0e8
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1458,6 +1458,16 @@ class WirePluginTest {
buildCacheDir.deleteRecursively()
}

@Test
fun configurationCacheFailure() {
val fixtureRoot = File("src/test/projects/configuration-cache-failure")

val result = gradleRunner.runFixture(fixtureRoot) {
withArguments("clean", "generateMainProtos", "--stacktrace", "--info").build()
}
assertThat(result.task(":generateMainProtos")?.outcome).isEqualTo(TaskOutcome.SUCCESS)
}

private fun GradleRunner.runFixture(
root: File,
action: GradleRunner.() -> BuildResult,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
plugins {
id("com.squareup.wire")
id("org.jetbrains.kotlin.jvm") version "1.9.22"
}

val genProtosDir = "$buildDir/generated/proto"

tasks.register("genProto") {
val outFile = project.file("$genProtosDir/period.proto")
outputs.file(outFile)
doLast {
outFile.writeText("""
syntax = "proto2";
enum Period {
CRETACEOUS = 1;
}
""")
}
}

tasks.matching { it.name == "generateMainProtos" }.configureEach {
dependsOn("genProto")
}

wire {
sourcePath {
srcDir("src/main/proto/")
}

sourcePath {
srcDir(genProtosDir)
}

kotlin {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
org.gradle.caching=false
org.gradle.unsafe.configuration-cache=true
org.gradle.configuration-cache=true
VERSION_NAME=5.0.0-SNAPSHOT
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
syntax = "proto2";

import "period.proto";

message Dinosaur {
optional Period period = 5;
}

0 comments on commit f7ad0e8

Please sign in to comment.