From f456b8b3a61475f5306007e992ac05eb422ad980 Mon Sep 17 00:00:00 2001 From: John Rodriguez Date: Thu, 28 Sep 2023 14:03:16 -0400 Subject: [PATCH] Externalize snapshot output dir (#1110) --- .../main/java/app/cash/paparazzi/gradle/PaparazziPlugin.kt | 1 + paparazzi/build.gradle | 4 ++++ .../src/main/java/app/cash/paparazzi/HtmlReportWriter.kt | 2 +- .../src/main/java/app/cash/paparazzi/SnapshotVerifier.kt | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/paparazzi-gradle-plugin/src/main/java/app/cash/paparazzi/gradle/PaparazziPlugin.kt b/paparazzi-gradle-plugin/src/main/java/app/cash/paparazzi/gradle/PaparazziPlugin.kt index 475ab20dc1..327b2c299a 100644 --- a/paparazzi-gradle-plugin/src/main/java/app/cash/paparazzi/gradle/PaparazziPlugin.kt +++ b/paparazzi-gradle-plugin/src/main/java/app/cash/paparazzi/gradle/PaparazziPlugin.kt @@ -227,6 +227,7 @@ class PaparazziPlugin : Plugin { test.systemProperties["paparazzi.project.dir"] = projectDirectory.toString() test.systemProperties["paparazzi.build.dir"] = buildDirectory.get().toString() test.systemProperties["paparazzi.report.dir"] = reportOutputDir.get().toString() + test.systemProperties["paparazzi.snapshot.dir"] = snapshotOutputDir.toString() test.systemProperties["paparazzi.artifacts.cache.dir"] = gradleUserHomeDir.path test.systemProperties["kotlinx.coroutines.main.delay"] = true test.systemProperties.putAll(project.properties.filterKeys { it.startsWith("app.cash.paparazzi") }) diff --git a/paparazzi/build.gradle b/paparazzi/build.gradle index bad0eb0d10..f066cc5345 100644 --- a/paparazzi/build.gradle +++ b/paparazzi/build.gradle @@ -134,6 +134,10 @@ tasks.withType(Test).configureEach { "paparazzi.report.dir", project.extensions.getByType(ReportingExtension).baseDirectory.dir("paparazzi").get().toString() ) + systemProperty( + "paparazzi.snapshot.dir", + project.layout.projectDirectory.dir("src/test/snapshots").toString() + ) systemProperty( "paparazzi.artifacts.cache.dir", project.gradle.gradleUserHomeDir.path diff --git a/paparazzi/src/main/java/app/cash/paparazzi/HtmlReportWriter.kt b/paparazzi/src/main/java/app/cash/paparazzi/HtmlReportWriter.kt index 3fffe0168e..392afbd662 100644 --- a/paparazzi/src/main/java/app/cash/paparazzi/HtmlReportWriter.kt +++ b/paparazzi/src/main/java/app/cash/paparazzi/HtmlReportWriter.kt @@ -60,7 +60,7 @@ import javax.imageio.ImageIO class HtmlReportWriter @JvmOverloads constructor( private val runName: String = defaultRunName(), private val rootDirectory: File = File(System.getProperty("paparazzi.report.dir")), - snapshotRootDirectory: File = File("src/test/snapshots") + snapshotRootDirectory: File = File(System.getProperty("paparazzi.snapshot.dir")) ) : SnapshotHandler { private val runsDirectory: File = File(rootDirectory, "runs") private val imagesDirectory: File = File(rootDirectory, "images") diff --git a/paparazzi/src/main/java/app/cash/paparazzi/SnapshotVerifier.kt b/paparazzi/src/main/java/app/cash/paparazzi/SnapshotVerifier.kt index 564cd2e80b..2f9b566274 100644 --- a/paparazzi/src/main/java/app/cash/paparazzi/SnapshotVerifier.kt +++ b/paparazzi/src/main/java/app/cash/paparazzi/SnapshotVerifier.kt @@ -23,7 +23,7 @@ import javax.imageio.ImageIO class SnapshotVerifier @JvmOverloads constructor( private val maxPercentDifference: Double, - rootDirectory: File = File("src/test/snapshots") + rootDirectory: File = File(System.getProperty("paparazzi.snapshot.dir")) ) : SnapshotHandler { private val imagesDirectory: File = File(rootDirectory, "images") private val videosDirectory: File = File(rootDirectory, "videos")