Skip to content

Commit

Permalink
Don't log in Gradle when emitting a file (#3041)
Browse files Browse the repository at this point in the history
* Don't log in Gradle when emitting a file

It's too chatty. Other compilers and generators don't do this.

* Fix tests

---------

Co-authored-by: Benoît Quenaudon <benoit@quenaudon.com>
  • Loading branch information
squarejesse and oldergod authored Jul 23, 2024
1 parent 6237792 commit e672dc4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ internal object GradleWireLogger : WireLogger {
}

override fun artifactHandled(outputPath: Path, qualifiedName: String, targetName: String) {
slf4jLogger.info("Writing $qualifiedName to $outputPath (target=$targetName)")
slf4jLogger.debug("Writing {} to {} (target={})", qualifiedName, outputPath, targetName)
}

override fun artifactSkipped(type: ProtoType, targetName: String) {
slf4jLogger.info("Skipping $type (target=$targetName)")
slf4jLogger.debug("Skipping {} (target={})", type, targetName)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -554,9 +554,8 @@ class WirePluginTest {
val result = gradleRunner.runFixture(fixtureRoot) { build() }

assertThat(result.task(":generateProtos")).isNotNull()
assertThat(result.output)
.doesNotContain("Writing com.squareup.geology.Period")

assertThat(File(fixtureRoot, "build/generated/source/wire/com/squareup/geology/Period.kt")).doesNotExist()
val generatedProto =
File(fixtureRoot, "build/generated/source/wire/com/squareup/dinosaurs/Dinosaur.kt")
assertThat(generatedProto).exists()
Expand All @@ -572,9 +571,8 @@ class WirePluginTest {
val result = gradleRunner.runFixture(fixtureRoot) { build() }

assertThat(result.task(":generateProtos")).isNotNull()
assertThat(result.output)
.doesNotContain("Writing com.squareup.geology.Period")

assertThat(File(fixtureRoot, "build/generated/source/wire/com/squareup/geology/Period.kt")).doesNotExist()
val generatedProto =
File(fixtureRoot, "build/generated/source/wire/com/squareup/dinosaurs/Dinosaur.kt")
assertThat(generatedProto).exists()
Expand Down Expand Up @@ -618,9 +616,8 @@ class WirePluginTest {
val result = gradleRunner.runFixture(fixtureRoot) { build() }

assertThat(result.task(":generateProtos")).isNotNull()
assertThat(result.output)
.doesNotContain("Writing com.squareup.geology.Period")

assertThat(File(fixtureRoot, "build/generated/source/wire/com/squareup/geology/Period.kt")).doesNotExist()
val generatedProto =
File(fixtureRoot, "build/generated/source/wire/com/squareup/dinosaurs/Dinosaur.kt")
assertThat(generatedProto).exists()
Expand All @@ -637,10 +634,10 @@ class WirePluginTest {
val result = gradleRunner.runFixture(fixtureRoot) { build() }

assertThat(result.task(":generateProtos")).isNotNull()
assertThat(File(outputRoot, "com/squareup/geology/Period.kt")).exists()
assertThat(File(outputRoot, "com/squareup/dinosaurs/Dinosaur.kt"))
.exists()
.content().doesNotContain("val name")
assertThat(File(outputRoot, "com/squareup/geology/Period.kt"))
}

@Test
Expand Down Expand Up @@ -975,7 +972,7 @@ class WirePluginTest {
"--stacktrace",
"-Dkjs=$kmpJsEnabled",
"-Dknative=$kmpNativeEnabled",
"--info",
"--debug",
).build()
}

Expand Down Expand Up @@ -1287,7 +1284,7 @@ class WirePluginTest {

val fixtureRoot = File("src/test/projects/cache-include-paths-1")
val result = gradleRunner.runFixture(fixtureRoot) {
withArguments("generateProtos", "--build-cache", "--stacktrace", "--info").build()
withArguments("generateProtos", "--build-cache", "--stacktrace", "--debug").build()
}

assertThat(result.task(":generateProtos")).isNotNull()
Expand All @@ -1299,7 +1296,7 @@ class WirePluginTest {
assertThat(buildCacheDir.exists()).isTrue()

val cachedResult = gradleRunner.runFixture(fixtureRoot) {
withArguments("generateProtos", "--build-cache", "--stacktrace", "--info").build()
withArguments("generateProtos", "--build-cache", "--stacktrace", "--debug").build()
}

assertThat(cachedResult.task(":generateProtos")).isNotNull()
Expand Down Expand Up @@ -1339,7 +1336,7 @@ class WirePluginTest {
// expect the new task to run again, without using the cache.
val modifiedFixtureRoot = File("src/test/projects/cache-include-paths-2")
val modifiedResult = gradleRunner.runFixture(modifiedFixtureRoot) {
withArguments("generateProtos", "--build-cache", "--stacktrace", "--info").build()
withArguments("generateProtos", "--build-cache", "--stacktrace", "--debug").build()
}

assertThat(modifiedResult.task(":generateProtos")).isNotNull()
Expand Down

0 comments on commit e672dc4

Please sign in to comment.