Add assertion checking if task was put into build cache.

^KT-45745 In Progress
This commit is contained in:
Yahor Berdnikau
2021-08-06 15:26:32 +02:00
parent 2574c00dd9
commit e949a0d38d
@@ -63,7 +63,9 @@ fun BuildResult.assertTasksFromCache(vararg tasks: String) {
tasks.forEach { task ->
assert(task(task)?.outcome == TaskOutcome.FROM_CACHE) {
printBuildOutput()
"Task $task didn't have 'FROM_CACHE' state: ${task(task)?.outcome}"
val occurrences = output.lineSequence().filter { it.contains("> Task $task") }
System.err.println("ZZZ: task results ${occurrences.joinToString(separator = "\n")}")
"Task $task didn't have 'FROM-CACHE' state: ${task(task)?.outcome}"
}
}
}
@@ -79,3 +81,12 @@ fun BuildResult.assertTasksNoSource(vararg tasks: String) {
}
}
}
/**
* Assert new cache entry was created for given [tasks].
*/
fun BuildResult.assertTasksPackedToCache(vararg tasks: String) {
tasks.forEach {
assertOutputContains("Stored cache entry for task '$it' with cache key ")
}
}