Skip to content

Commit

Permalink
Use file property instead of directory
Browse files Browse the repository at this point in the history
  • Loading branch information
geoff-powell committed Nov 20, 2024
1 parent 072a7ec commit 995defe
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import org.gradle.api.file.FileCollection
import org.gradle.api.internal.artifacts.transform.UnzipTransform
import org.gradle.api.internal.tasks.testing.report.TestReporter
import org.gradle.api.logging.LogLevel.LIFECYCLE
import org.gradle.api.logging.LogLevel.WARN
import org.gradle.api.provider.Provider
import org.gradle.api.provider.ProviderFactory
import org.gradle.api.reporting.ReportingExtension
Expand All @@ -45,6 +46,7 @@ import org.gradle.api.tasks.PathSensitivity
import org.gradle.api.tasks.options.Option
import org.gradle.api.tasks.testing.AbstractTestTask
import org.gradle.api.tasks.testing.Test
import org.gradle.internal.cc.base.logger
import org.gradle.internal.operations.BuildOperationExecutor
import org.gradle.internal.operations.BuildOperationRunner
import org.gradle.internal.os.OperatingSystem
Expand Down Expand Up @@ -258,12 +260,24 @@ public class PaparazziPlugin @Inject constructor(
test.doFirst {
// Note: these are lazy properties that are not resolvable in the Gradle configuration phase.
// They need special handling, so they're added as inputs.property above, and systemProperty here.
val isVerificationTask = isVerifyRun.get()

test.systemProperties["paparazzi.layoutlib.runtime.root"] =
layoutlibNativeRuntimeFileCollection.singleFile.absolutePath
test.systemProperties["paparazzi.layoutlib.resources.root"] =
layoutlibResourcesFileCollection.singleFile.absolutePath
test.systemProperties["paparazzi.test.record"] = isRecordRun.get()
test.systemProperties["paparazzi.test.verify"] = isVerifyRun.get()
test.systemProperties["paparazzi.test.verify"] = isVerificationTask

if (isVerificationTask && snapshotOutputDir.asFile.exists().not()) {
test.logger.log(
WARN,
"""
Snapshot directory not found: ${snapshotOutputDir.asFile.path}
Please run the `recordPaparazzi${variantSlug}` task to generate snapshots.
""".trimIndent()
)
}
}

test.doLast {
Expand Down Expand Up @@ -302,6 +316,7 @@ public class PaparazziPlugin @Inject constructor(
val osArch = System.getProperty("os.arch").lowercase(Locale.US)
if (osArch.startsWith("x86")) "mac" else "mac-arm"
}

operatingSystem.isWindows -> "win"
else -> "linux"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ class PaparazziPluginTest {
.runFixture(fixtureRoot) { build() }

assertThat(result.task(":verifyPaparazziDebug")?.outcome).isEqualTo(SUCCESS)
assertThat(result.output).contains("Snapshot directory not found: ")
assertThat(result.output).contains("Please run the `recordPaparazziDebug` task to generate snapshots.")
}

@Test
Expand Down

0 comments on commit 995defe

Please sign in to comment.