Provide test source mapping data for separate and non-separate compilation

Compilation in same module or in separate ones
This commit is contained in:
Mikhael Bogdanov
2017-12-20 14:22:39 +01:00
parent f4f7c83eeb
commit b65dcf27ee
6 changed files with 163 additions and 10 deletions
@@ -112,7 +112,7 @@ test/_1Kt$kValue$1
1#1,38:1
*E
// FILE: 2.smap
// FILE: 2.smap-nonseparate-compilation
SMAP
2.kt
@@ -137,4 +137,66 @@ _2Kt
*L
5#1,5:9
5#1:14
*E
// FILE: 2.smap-separate-compilation
SMAP
2.kt
Kotlin
*S Kotlin
*F
+ 1 2.kt
_2Kt
+ 2 1.kt
test/_1Kt
+ 3 1.kt
test/_1Kt$lParams$1
*L
1#1,8:1
31#2,5:9
32#3:14
*E
*S KotlinDebug
*F
+ 1 2.kt
_2Kt
*L
5#1,5:9
5#1:14
*E
SMAP
1.kt
Kotlin
*S Kotlin
*F
+ 1 1.kt
test/_1Kt$lParams$1$1
+ 2 1.kt
test/_1Kt
*L
1#1,38:1
29#2:39
*E
*S KotlinDebug
*F
+ 1 1.kt
test/_1Kt$lParams$1$1
*L
32#1:39
*E
SMAP
1.kt
Kotlin
*S Kotlin
*F
+ 1 1.kt
test/_1Kt$kValue$1
+ 2 1.kt
test/_1Kt$lParams$1$1
*L
1#1,38:1
32#2:39
*E
@@ -101,7 +101,7 @@ test/_1Kt$kValue$1
1#1,38:1
*E
// FILE: 2.smap
// FILE: 2.smap-nonseparate-compilation
SMAP
2.kt
@@ -128,4 +128,47 @@ _2Kt
5#1,5:9
5#1:15
5#1:14
*E
// FILE: 2.smap-separate-compilation
SMAP
2.kt
Kotlin
*S Kotlin
*F
+ 1 2.kt
_2Kt
+ 2 1.kt
test/_1Kt
+ 3 1.kt
test/_1Kt$lParams$1
*L
1#1,8:1
31#2,5:9
29#2:15
32#3:14
*E
*S KotlinDebug
*F
+ 1 2.kt
_2Kt
*L
5#1,5:9
5#1:15
5#1:14
*E
SMAP
1.kt
Kotlin
*S Kotlin
*F
+ 1 1.kt
test/_1Kt$kValue$1
+ 2 1.kt
test/_1Kt$lParams$1
*L
1#1,38:1
32#2:39
*E
@@ -103,7 +103,7 @@ test/_1Kt$kValue$1
1#1,38:1
*E
// FILE: 2.smap
// FILE: 2.smap-nonseparate-compilation
SMAP
2.kt
@@ -130,4 +130,46 @@ _2Kt
5#1,5:11
5#1:17
5#1:16
*E
// FILE: 2.smap-separate-compilation
SMAP
2.kt
Kotlin
*S Kotlin
*F
+ 1 2.kt
_2Kt
+ 2 1.kt
test/_1Kt
+ 3 1.kt
test/_1Kt$lParams$1
*L
1#1,10:1
31#2,5:11
29#2:17
32#3:16
*E
*S KotlinDebug
*F
+ 1 2.kt
_2Kt
*L
5#1,5:11
5#1:17
5#1:16
*E
SMAP
1.kt
Kotlin
*S Kotlin
*F
+ 1 1.kt
test/_1Kt$kValue$1
+ 2 1.kt
test/_1Kt$lParams$1
*L
1#1,38:1
32#2:39
*E
@@ -23,7 +23,7 @@ abstract class AbstractBlackBoxInlineCodegenTest : AbstractBlackBoxCodegenTest()
super.doMultiFileTest(wholeFile, files, javaFilesDir)
try {
InlineTestUtil.checkNoCallsToInline(initializedClassLoader.allGeneratedFiles.filterClassFiles(), myFiles.psiFiles)
SMAPTestUtil.checkSMAP(files, generateClassesInFile().getClassFiles())
SMAPTestUtil.checkSMAP(files, generateClassesInFile().getClassFiles(), false)
}
catch (e: Throwable) {
println(generateToText())
@@ -25,7 +25,7 @@ abstract class AbstractCompileKotlinAgainstInlineKotlinTest : AbstractCompileKot
val allGeneratedFiles = factory1.asList() + factory2.asList()
val sourceFiles = factory1.inputFiles + factory2.inputFiles
InlineTestUtil.checkNoCallsToInline(allGeneratedFiles.filterClassFiles(), sourceFiles)
SMAPTestUtil.checkSMAP(files, allGeneratedFiles.filterClassFiles())
SMAPTestUtil.checkSMAP(files, allGeneratedFiles.filterClassFiles(), true)
}
catch (e: Throwable) {
println("FIRST:\n\n${factory1.createText()}\n\nSECOND:\n\n${factory2.createText()}")
@@ -45,8 +45,8 @@ object SMAPTestUtil {
}
}
private fun extractSmapFromTestDataFile(file: CodegenTestCase.TestFile): SMAPAndFile? {
if (!file.name.endsWith(".smap")) return null
private fun extractSmapFromTestDataFile(file: CodegenTestCase.TestFile, separateCompilation: Boolean): SMAPAndFile? {
if (!checkExtension(file, separateCompilation)) return null
val content = buildString {
StringReader(file.content).forEachLine { line ->
@@ -60,10 +60,13 @@ object SMAPTestUtil {
return SMAPAndFile(if (content.isNotEmpty()) content else null, SMAPAndFile.getPath(file.name), "NOT_SORTED")
}
fun checkSMAP(inputFiles: List<CodegenTestCase.TestFile>, outputFiles: Iterable<OutputFile>) {
private fun checkExtension(file: CodegenTestCase.TestFile, separateCompilation: Boolean) =
file.name.run { endsWith(".smap") || if (separateCompilation) endsWith(".smap-separate-compilation") else endsWith(".smap-nonseparate-compilation") }
fun checkSMAP(inputFiles: List<CodegenTestCase.TestFile>, outputFiles: Iterable<OutputFile>, separateCompilation: Boolean) {
if (!GENERATE_SMAP) return
val sourceData = inputFiles.mapNotNull { extractSmapFromTestDataFile(it) }
val sourceData = inputFiles.mapNotNull { extractSmapFromTestDataFile(it, separateCompilation) }
val compiledSmaps = extractSMAPFromClasses(outputFiles)
val compiledData = compiledSmaps.groupBy {
it.sourceFile
@@ -73,7 +76,10 @@ object SMAPTestUtil {
}.associateBy { it.sourceFile }
for (source in sourceData) {
val ktFileName = "/" + source.sourceFile.replace(".smap", ".kt")
val ktFileName = "/" + source.sourceFile.
replace(".smap-nonseparate-compilation", ".kt").
replace(".smap-separate-compilation", ".kt").
replace(".smap", ".kt")
val data = compiledData[ktFileName]
Assert.assertEquals("Smap data differs for $ktFileName", normalize(source.smap), normalize(data?.smap))
}