Skip to content

Commit

Permalink
Merge pull request #362 from takahirom/remove-unneeded-cache-invalida…
Browse files Browse the repository at this point in the history
…tion

Remove unneeded cache invalidation
  • Loading branch information
takahirom committed May 17, 2024
2 parents 53bc135 + 679b6b8 commit fbf270d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,12 @@ class RoborazziGradleProjectTest {
}

@Test
fun recordWhenRemovedOutput() {
fun whenRecordAndRemovedOutputAndRecordThenSkipAndRestoreTheImages() {
RoborazziGradleProject(testProjectDir).apply {
record()
removeRoborazziOutputDir()
// should not be skipped even if tests and sources are not changed
// when output directory is removed
val output = record().output
assertNotSkipped(output)
assertSkipped(output)

checkResultsSummaryFileExists()
checkRecordedFileExists("$screenshotAndName.testCapture.png")
Expand Down Expand Up @@ -92,10 +90,6 @@ class RoborazziGradleProjectTest {
fun recordWhenRunTwice() {
RoborazziGradleProject(testProjectDir).apply {
record()
// files are changed so should not be skipped
val output1 = record().output
assertNotSkipped(output1)
// files are not changed so should be skipped
val output2 = record().output
assertSkipped(output2)

Expand All @@ -112,10 +106,6 @@ class RoborazziGradleProjectTest {
val customDirFromGradle = "src/screenshots/roborazzi_customdir_from_gradle"
appBuildFile.customOutputDirPath = customDirFromGradle
record()
// files are changed so should not be skipped
val output1 = record().output
assertNotSkipped(output1)
// files are not changed so should be skipped
val output2 = record().output
assertSkipped(output2)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,23 +300,6 @@ abstract class RoborazziPlugin : Plugin<Project> {
testTaskProvider
.configureEach { test ->
val resultsDir = resultDirFileProperty.get().asFile
if (restoreOutputDirRoborazziTaskProvider.isPresent) {
test.inputs.dir(restoreOutputDirRoborazziTaskProvider.map {
if (!it.outputDir.get().asFile.exists()) {
it.outputDir.get().asFile.mkdirs()
}
test.infoln("Roborazzi: Set input dir ${it.outputDir.get()} to test task")
it.outputDir
})
} else {
test.inputs.dir(outputDir.map {
if (!it.asFile.exists()) {
it.asFile.mkdirs()
}
test.infoln("Roborazzi: Set input dir $it to test task")
it
})
}
test.outputs.dir(intermediateDirForEachVariant.map {
test.infoln("Roborazzi: Set output dir $it to test task")
it
Expand All @@ -343,12 +326,6 @@ abstract class RoborazziPlugin : Plugin<Project> {
"roborazziProperties" to roborazziProperties,
)
)
test.outputs.upToDateWhen {
val doesRoborazziRun = doesRoborazziRunProvider.get()
val inputDirEmpty = outputDir.get().asFile.listFiles()?.isEmpty() ?: true
test.infoln("Roborazzi: test.outputs.upToDateWhen !(doesRoborazziRun:$doesRoborazziRun && inputDirEmpty:$inputDirEmpty)")
!(doesRoborazziRun && inputDirEmpty)
}
test.doFirst {
val doesRoborazziRun =
doesRoborazziRunProvider.get()
Expand Down

0 comments on commit fbf270d

Please sign in to comment.