Fix location mapping test on Windows
This commit is contained in:
+14
-7
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.gradle
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.gradle.tasks.USING_INCREMENTAL_COMPILATION_MESSAGE
|
import org.jetbrains.kotlin.gradle.tasks.USING_INCREMENTAL_COMPILATION_MESSAGE
|
||||||
import org.jetbrains.kotlin.gradle.util.*
|
import org.jetbrains.kotlin.gradle.util.*
|
||||||
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.zip.ZipFile
|
import java.util.zip.ZipFile
|
||||||
@@ -346,13 +347,22 @@ open class Kapt3IT : Kapt3BaseIT() {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testLocationMapping() {
|
fun testLocationMapping() {
|
||||||
|
fun String.modifyNumbers(fn: (Int) -> Int): String =
|
||||||
|
replace("\\d+".toRegex()) { fn(it.value.toInt()).toString() }
|
||||||
|
|
||||||
val project = Project("locationMapping", directoryPrefix = "kapt2")
|
val project = Project("locationMapping", directoryPrefix = "kapt2")
|
||||||
|
val regex = "((Test\\.java)|(test\\.kt)):(\\d+): error: GenError element".toRegex()
|
||||||
|
|
||||||
|
fun CompiledProject.getErrorMessages(): String =
|
||||||
|
regex.findAll(output)
|
||||||
|
.map { it.value }
|
||||||
|
.joinToString("\n") { if (isWindows) it.modifyNumbers { it + 1 } else it }
|
||||||
|
|
||||||
project.build("build") {
|
project.build("build") {
|
||||||
assertFailed()
|
assertFailed()
|
||||||
|
|
||||||
assertContains("Test.java:9: error: GenError element")
|
val expected = arrayOf(9, 17).joinToString("\n") { "Test.java:$it: error: GenError element" }
|
||||||
assertContains("Test.java:17: error: GenError element")
|
Assert.assertEquals(expected, getErrorMessages())
|
||||||
}
|
}
|
||||||
|
|
||||||
project.projectDir.getFileByName("build.gradle").modify {
|
project.projectDir.getFileByName("build.gradle").modify {
|
||||||
@@ -362,11 +372,8 @@ open class Kapt3IT : Kapt3BaseIT() {
|
|||||||
project.build("build") {
|
project.build("build") {
|
||||||
assertFailed()
|
assertFailed()
|
||||||
|
|
||||||
assertNotContains("Test.java:9: error: GenError element")
|
val expected = arrayOf(3, 7).joinToString("\n") { "test.kt:$it: error: GenError element" }
|
||||||
assertNotContains("Test.java:17: error: GenError element")
|
Assert.assertEquals(expected, getErrorMessages())
|
||||||
|
|
||||||
assertContains("test.kt:3: error: GenError element")
|
|
||||||
assertContains("test.kt:7: error: GenError element")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user