Improve test error message
This commit is contained in:
+20
-7
@@ -367,17 +367,30 @@ abstract class BaseGradleIT {
|
|||||||
weakTesting: Boolean = false,
|
weakTesting: Boolean = false,
|
||||||
tasks: List<String>) {
|
tasks: List<String>) {
|
||||||
for (task in tasks) {
|
for (task in tasks) {
|
||||||
assertCompiledKotlinSources(sources, weakTesting, getOutputForTask(task))
|
assertCompiledKotlinSources(sources, weakTesting, getOutputForTask(task), suffix = " in task ${task}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun CompiledProject.assertCompiledKotlinSources(sources: Iterable<String>, weakTesting: Boolean = false, output: String = this.output): CompiledProject =
|
fun CompiledProject.assertCompiledKotlinSources(
|
||||||
if (weakTesting)
|
expectedSources: Iterable<String>,
|
||||||
assertContainFiles(sources, getCompiledKotlinSources(output).projectRelativePaths(this.project), "Compiled Kotlin files differ:\n ")
|
weakTesting: Boolean = false,
|
||||||
else
|
output: String = this.output,
|
||||||
assertSameFiles(sources, getCompiledKotlinSources(output).projectRelativePaths(this.project), "Compiled Kotlin files differ:\n ")
|
suffix: String = ""
|
||||||
|
): CompiledProject {
|
||||||
|
val messagePrefix = "Compiled Kotlin files differ${suffix}:\n "
|
||||||
|
val actualSources = getCompiledKotlinSources(output).projectRelativePaths(this.project)
|
||||||
|
return if (weakTesting) {
|
||||||
|
assertContainFiles(expectedSources, actualSources, messagePrefix)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
assertSameFiles(expectedSources, actualSources, messagePrefix)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun CompiledProject.assertCompiledJavaSources(sources: Iterable<String>, weakTesting: Boolean = false): CompiledProject =
|
fun CompiledProject.assertCompiledJavaSources(
|
||||||
|
sources: Iterable<String>,
|
||||||
|
weakTesting: Boolean = false
|
||||||
|
): CompiledProject =
|
||||||
if (weakTesting)
|
if (weakTesting)
|
||||||
assertContainFiles(sources, compiledJavaSources.projectRelativePaths(this.project), "Compiled Java files differ:\n ")
|
assertContainFiles(sources, compiledJavaSources.projectRelativePaths(this.project), "Compiled Java files differ:\n ")
|
||||||
else
|
else
|
||||||
|
|||||||
+2
-3
@@ -210,12 +210,11 @@ abstract class KaptIncrementalBaseIT(val shouldUseStubs: Boolean, val useKapt3:
|
|||||||
assertKapt3FullyExecuted()
|
assertKapt3FullyExecuted()
|
||||||
|
|
||||||
val useBKt = project.projectDir.getFileByName("useB.kt")
|
val useBKt = project.projectDir.getFileByName("useB.kt")
|
||||||
assertCompiledKotlinSources(project.relativize(bKt, useBKt),
|
assertCompiledKotlinSources(project.relativize(bKt, useBKt), tasks = listOf("kaptGenerateStubsKotlin"))
|
||||||
output = getOutputForTask("kaptGenerateStubsKotlin"))
|
|
||||||
|
|
||||||
// java removal is detected
|
// java removal is detected
|
||||||
assertCompiledKotlinSources(project.relativize(project.projectDir.allKotlinFiles()),
|
assertCompiledKotlinSources(project.relativize(project.projectDir.allKotlinFiles()),
|
||||||
output = getOutputForTask("compileKotlin"))
|
tasks = listOf("kaptGenerateStubsKotlin"))
|
||||||
}
|
}
|
||||||
else if (shouldUseStubs) {
|
else if (shouldUseStubs) {
|
||||||
// java removal is detected
|
// java removal is detected
|
||||||
|
|||||||
Reference in New Issue
Block a user