Add truth for better badging diff output

Change-Id: Id3fab0107bc08adf44ddf07a30e0327e06897d47
pull/1085/head
Alex Vanyo 1 year ago
parent 646c9cf4de
commit 5df9cce37c

@ -41,6 +41,7 @@ dependencies {
compileOnly(libs.firebase.performance.gradlePlugin)
compileOnly(libs.kotlin.gradlePlugin)
compileOnly(libs.ksp.gradlePlugin)
implementation(libs.truth)
}
tasks {

@ -20,8 +20,8 @@ import com.android.build.api.artifact.SingleArtifact
import com.android.build.api.variant.ApplicationAndroidComponentsExtension
import com.android.build.gradle.BaseExtension
import com.android.SdkConstants
import com.google.common.truth.Truth.assertWithMessage
import org.gradle.api.DefaultTask
import org.gradle.api.GradleException
import org.gradle.api.Project
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.file.RegularFileProperty
@ -40,7 +40,6 @@ import org.gradle.kotlin.dsl.register
import org.gradle.language.base.plugins.LifecycleBasePlugin
import org.gradle.process.ExecOperations
import java.io.File
import java.nio.file.Files
import javax.inject.Inject
@CacheableTask
@ -98,17 +97,12 @@ abstract class CheckBadgingTask : DefaultTask() {
@TaskAction
fun taskAction() {
if (
Files.mismatch(
goldenBadging.get().asFile.toPath(),
generatedBadging.get().asFile.toPath(),
) != -1L
) {
throw GradleException(
"Generated badging is different from golden badging! " +
"If this change is intended, run ./gradlew ${updateBadgingTaskName.get()}",
)
}
assertWithMessage(
"Generated badging is different from golden badging! " +
"If this change is intended, run ./gradlew ${updateBadgingTaskName.get()}",
)
.that(generatedBadging.get().asFile.readText())
.isEqualTo(goldenBadging.get().asFile.readText())
}
}

@ -57,6 +57,7 @@ robolectric = "4.11.1"
roborazzi = "1.6.0"
room = "2.6.0"
secrets = "2.0.1"
truth = "1.1.5"
turbine = "1.0.0"
[libraries]
@ -140,6 +141,7 @@ roborazzi = { group = "io.github.takahirom.roborazzi", name = "roborazzi", versi
room-compiler = { group = "androidx.room", name = "room-compiler", version.ref = "room" }
room-ktx = { group = "androidx.room", name = "room-ktx", version.ref = "room" }
room-runtime = { group = "androidx.room", name = "room-runtime", version.ref = "room" }
truth = { group = "com.google.truth", name = "truth", version.ref = "truth" }
turbine = { group = "app.cash.turbine", name = "turbine", version.ref = "turbine" }
# Dependencies of the included build-logic

Loading…
Cancel
Save