Add test with other annotation, tests fix of #KT-2496

This commit is contained in:
Ilya Chernikov
2018-06-15 12:01:49 +02:00
parent e24a9d08f2
commit 29adf09b7e
2 changed files with 41 additions and 0 deletions
@@ -0,0 +1,5 @@
import kotlin.script.templates.*
@ScriptTemplateDefinition
abstract class TestScriptWithOtherAnnotation
@@ -156,6 +156,42 @@ class ScriptingCompilerPluginTest : TestCaseWithTmpdir() {
Assert.assertEquals(ExitCode.OK, exitCode)
}
fun testLazyScriptDefinitionOtherAnnotation() {
val defsOut = File(tmpdir, "testLazyScriptDefinition/out/otherAnn")
val defsSrc = File(TEST_DATA_DIR, "lazyDefinitions/definitions")
val defClasses = listOf("TestScriptWithOtherAnnotation")
val messageCollector = TestMessageCollector()
val definitionsCompileResult = KotlinToJVMBytecodeCompiler.compileBunchOfSources(
createEnvironment(defClasses.map { File(defsSrc, "$it.kt").canonicalPath }, defsOut, messageCollector) {
addJvmClasspathRoots(runtimeClasspath)
addJvmClasspathRoots(scriptingClasspath)
}
)
assertTrue(definitionsCompileResult) {
"Compilation of script definitions failed: $messageCollector"
}
val templatesDir = File(defsOut, SCRIPT_DEFINITION_MARKERS_PATH).also { it.mkdirs() }
for (def in defClasses) {
File(templatesDir, def).createNewFile()
}
messageCollector.clear()
discoverScriptTemplatesInClasspath(listOf(defsOut), emptyList(), this::class.java.classLoader, emptyMap(), messageCollector).toList()
assertTrue(
messageCollector.messages.isNotEmpty()
&& messageCollector.messages.all { it.message.contains("s not marked with any known kotlin script annotation") }
) {
"Unexpected messages from discovery sequence:\n$messageCollector"
}
}
}
class TestMessageCollector : MessageCollector {