Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 16a27f5

Browse files
committed
Kotlin: Provide a way for tests to cause an exception
1 parent 89eae24 commit 16a27f5

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,15 @@ open class KotlinFileExtractor(
5050
val pkgId = extractPackage(pkg)
5151
tw.writeHasLocation(id, locId)
5252
tw.writeCupackage(id, pkgId)
53+
54+
val exceptionOnFile = System.getenv("CODEQL_KOTLIN_INTERNAL_EXCEPTION_WHILE_EXTRACTING_FILE")
55+
if(exceptionOnFile != null) {
56+
@OptIn(kotlin.ExperimentalStdlibApi::class) // Annotation required by kotlin versions < 1.5
57+
if(exceptionOnFile.lowercase() == file.name.lowercase()) {
58+
throw Exception("Internal testing exception")
59+
}
60+
}
61+
5362
file.declarations.map { extractDeclaration(it) }
5463
CommentExtractor(this, file, tw.fileId).extract()
5564
}

0 commit comments

Comments
 (0)