Fix BuildCacheIT and BuildCacheRelocationIT
* Adjust the log checks for newer Gradle versions * Use AGP 3.6.0 and Gradle 5.6.1 as the older version
This commit is contained in:
committed by
Sergey Igushkin
parent
71a45e56d7
commit
603bae398f
+13
-7
@@ -34,7 +34,7 @@ class BuildCacheIT : BaseGradleIT() {
|
|||||||
|
|
||||||
build("assemble") {
|
build("assemble") {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
assertContains("Packing task ':compileKotlin'")
|
assertTaskPackedToCache(":compileKotlin")
|
||||||
}
|
}
|
||||||
|
|
||||||
build("clean", "assemble", "-Dkotlin.caching.enabled=false") {
|
build("clean", "assemble", "-Dkotlin.caching.enabled=false") {
|
||||||
@@ -49,7 +49,7 @@ class BuildCacheIT : BaseGradleIT() {
|
|||||||
|
|
||||||
build("assemble") {
|
build("assemble") {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
assertContains("Packing task ':compileKotlin'")
|
assertTaskPackedToCache(":compileKotlin")
|
||||||
}
|
}
|
||||||
build("clean", "assemble") {
|
build("clean", "assemble") {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
@@ -65,7 +65,7 @@ class BuildCacheIT : BaseGradleIT() {
|
|||||||
build("assemble") {
|
build("assemble") {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
// Should store the output into the cache:
|
// Should store the output into the cache:
|
||||||
assertContains("Packing task ':compileKotlin'")
|
assertTaskPackedToCache(":compileKotlin")
|
||||||
}
|
}
|
||||||
|
|
||||||
val sourceFile = File(projectDir, "src/main/kotlin/helloWorld.kt")
|
val sourceFile = File(projectDir, "src/main/kotlin/helloWorld.kt")
|
||||||
@@ -75,7 +75,7 @@ class BuildCacheIT : BaseGradleIT() {
|
|||||||
|
|
||||||
build("assemble") {
|
build("assemble") {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
assertContains("Packing task ':compileKotlin'")
|
assertTaskPackedToCache(":compileKotlin")
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceFile.writeText(originalSource)
|
sourceFile.writeText(originalSource)
|
||||||
@@ -102,7 +102,7 @@ class BuildCacheIT : BaseGradleIT() {
|
|||||||
// First build, should be stored into the build cache:
|
// First build, should be stored into the build cache:
|
||||||
build("assemble") {
|
build("assemble") {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
assertContains("Packing task ':compileKotlin'")
|
assertTaskPackedToCache(":compileKotlin")
|
||||||
}
|
}
|
||||||
|
|
||||||
// A cache hit:
|
// A cache hit:
|
||||||
@@ -134,8 +134,8 @@ class BuildCacheIT : BaseGradleIT() {
|
|||||||
)
|
)
|
||||||
build(options = options, params = *arrayOf("clean", ":app:build")) {
|
build(options = options, params = *arrayOf("clean", ":app:build")) {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
assertContains("Packing task ':app:kaptGenerateStubsKotlin'")
|
assertTaskPackedToCache(":app:kaptGenerateStubsKotlin")
|
||||||
assertContains("Packing task ':app:kaptKotlin'")
|
assertTaskPackedToCache(":app:kaptKotlin")
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy project to a new location
|
// copy project to a new location
|
||||||
@@ -157,4 +157,10 @@ fun BaseGradleIT.Project.prepareLocalBuildCache(directory: File = File(projectDi
|
|||||||
}
|
}
|
||||||
File(projectDir, "settings.gradle").appendText("\nbuildCache.local.directory = '${directory.absolutePath.replace("\\", "/")}'")
|
File(projectDir, "settings.gradle").appendText("\nbuildCache.local.directory = '${directory.absolutePath.replace("\\", "/")}'")
|
||||||
return directory
|
return directory
|
||||||
|
}
|
||||||
|
|
||||||
|
internal fun BaseGradleIT.CompiledProject.assertTaskPackedToCache(taskPath: String) {
|
||||||
|
with(project.testCase) {
|
||||||
|
assertContainsRegex(Regex("(?:Packing|Stored cache entry for) task '${Regex.escape(taskPath)}'"))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+5
-2
@@ -28,10 +28,13 @@ import kotlin.test.assertEquals
|
|||||||
@RunWith(Parameterized::class)
|
@RunWith(Parameterized::class)
|
||||||
class BuildCacheRelocationIT : BaseGradleIT() {
|
class BuildCacheRelocationIT : BaseGradleIT() {
|
||||||
|
|
||||||
|
override val defaultGradleVersion: GradleVersionRequired
|
||||||
|
get() = GradleVersionRequired.AtLeast("5.6.1")
|
||||||
|
|
||||||
override fun defaultBuildOptions(): BuildOptions =
|
override fun defaultBuildOptions(): BuildOptions =
|
||||||
super.defaultBuildOptions().copy(
|
super.defaultBuildOptions().copy(
|
||||||
withBuildCache = true,
|
withBuildCache = true,
|
||||||
androidGradlePluginVersion = AGPVersion.v3_2_0,
|
androidGradlePluginVersion = AGPVersion.v3_6_0,
|
||||||
androidHome = KotlinTestUtils.findAndroidSdk()
|
androidHome = KotlinTestUtils.findAndroidSdk()
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -62,7 +65,7 @@ class BuildCacheRelocationIT : BaseGradleIT() {
|
|||||||
firstProject.build(*testCase.taskToExecute) {
|
firstProject.build(*testCase.taskToExecute) {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
firstOutputHashes = hashOutputFiles(outputRoots)
|
firstOutputHashes = hashOutputFiles(outputRoots)
|
||||||
cacheableTaskNames.forEach { assertContains("Packing task ':$it") }
|
cacheableTaskNames.forEach { assertTaskPackedToCache(":$it") }
|
||||||
}
|
}
|
||||||
|
|
||||||
workingDir = workingDirs[1]
|
workingDir = workingDirs[1]
|
||||||
|
|||||||
Reference in New Issue
Block a user