[PowerAssert] Add codegen tests

This commit is contained in:
Brian Norman
2023-11-17 12:31:19 -06:00
committed by Space Team
parent 9f5589614a
commit 305c53dd6e
164 changed files with 2308 additions and 1 deletions
@@ -30,7 +30,26 @@ import java.io.File
data class SourceFile(
private val irFile: IrFile,
) {
private val source: String = File(irFile.path).readText()
companion object {
private val KOTLIN_POWER_ASSERT_ADD_SRC_ROOTS = System.getProperty("KOTLIN_POWER_ASSERT_ADD_SRC_ROOTS") ?: ""
private val sourceRoots = listOf(".") + KOTLIN_POWER_ASSERT_ADD_SRC_ROOTS.split(",").map { it.trim() }
}
private val source: String = run {
File(irFile.path).also { file ->
if (file.exists()) {
return@run file.readText()
}
}
for (root in sourceRoots) {
val file = File(root, irFile.path)
if (file.exists()) {
return@run file.readText()
}
}
throw IllegalArgumentException("Unable to find source for IrFile: ${irFile.path}")
}
.replace("\r\n", "\n") // https://youtrack.jetbrains.com/issue/KT-41888
fun getSourceRangeInfo(element: IrElement): SourceRangeInfo {