Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid snapshotting sourceLink.localDirectory input #2807

Merged
merged 5 commits into from
Jan 13, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Check that changing localDirectory path invalidates task cache
  • Loading branch information
ilya-g committed Jan 13, 2023
commit 8abe7ead2770dc62a076da23e32a165777352a0f
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 20,8 @@ class BasicCachingIntegrationTest(override val versions: BuildVersions) : Abstra

@Test
fun execute() {
runAndAssertOutcome(TaskOutcome.SUCCESS)
runAndAssertOutcome(TaskOutcome.FROM_CACHE)
runAndAssertOutcomeAndContents(TaskOutcome.SUCCESS)
runAndAssertOutcomeAndContents(TaskOutcome.FROM_CACHE)
}

@Test
Expand All @@ -31,18 31,30 @@ class BasicCachingIntegrationTest(override val versions: BuildVersions) : Abstra
return replace(oldValue, newValue)
}
val projectKts = projectDir.resolve("build.gradle.kts")
val projectKtsText = projectKts.readText()

projectKts.readText()
.findAndReplace("localDirectory.set(file(\"src/main\"))", "localDirectory.set(projectDir)")
.findAndReplace("integration-tests/gradle/projects/it-basic/src/main", "integration-tests/gradle/projects/it-basic")
projectKts.writeText(projectKtsText)
.also { projectKts.writeText(it) }

runAndAssertOutcome(TaskOutcome.SUCCESS)
runAndAssertOutcomeAndContents(TaskOutcome.SUCCESS)
projectDir.resolve("unrelated.txt").writeText("modified")
// despite projectDir is used as an input in localDirectory, changing its contents shouldn't invalidate the cache
runAndAssertOutcome(TaskOutcome.FROM_CACHE)
runAndAssertOutcomeAndContents(TaskOutcome.FROM_CACHE)

projectKts.readText()
.findAndReplace("localDirectory.set(projectDir)", "localDirectory.set(file(\"src\"))")
.also { projectKts.writeText(it) }
// changing localDirectory path invalidates cached task results
runAndAssertOutcome(TaskOutcome.SUCCESS)
}


private fun runAndAssertOutcomeAndContents(expectedOutcome: TaskOutcome) {
runAndAssertOutcome(expectedOutcome)
File(projectDir, "build/dokka/html").assertHtmlOutputDir()
}

private fun runAndAssertOutcome(expectedOutcome: TaskOutcome) {
val result = createGradleRunner(
"clean",
Expand All @@ -54,7 66,5 @@ class BasicCachingIntegrationTest(override val versions: BuildVersions) : Abstra
).buildRelaxed()

assertEquals(expectedOutcome, assertNotNull(result.task(":dokkaHtml")).outcome)

File(projectDir, "build/dokka/html").assertHtmlOutputDir()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 21,11 @@ class GradleRelocatedCachingIntegrationTest(override val versions: BuildVersions

@Test
fun execute() {
runAndAssertOutcome(projectFolder(1), TaskOutcome.SUCCESS)
runAndAssertOutcome(projectFolder(2), TaskOutcome.FROM_CACHE)
runAndAssertOutcomeAndContents(projectFolder(1), TaskOutcome.SUCCESS)
runAndAssertOutcomeAndContents(projectFolder(2), TaskOutcome.FROM_CACHE)
}

private fun runAndAssertOutcome(project: File, expectedOutcome: TaskOutcome) {
private fun runAndAssertOutcomeAndContents(project: File, expectedOutcome: TaskOutcome) {
val result = createGradleRunner("clean", "dokkaHtml", "-i", "-s", "-Dorg.gradle.caching.debug=true", "--build-cache")
.withProjectDir(project)
.buildRelaxed()
Expand Down