Add kotlinx-html test

Among other things it tests the packagePartProvider fix above
This commit is contained in:
Ilya Chernikov
2019-11-18 18:09:26 +01:00
parent 4439582d23
commit 615624802c
2 changed files with 38 additions and 0 deletions
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.mainKts.test
import junit.framework.Assert import junit.framework.Assert
import org.jetbrains.kotlin.scripting.compiler.plugin.runWithK2JVMCompiler import org.jetbrains.kotlin.scripting.compiler.plugin.runWithK2JVMCompiler
import org.jetbrains.kotlin.scripting.compiler.plugin.runWithKotlinc import org.jetbrains.kotlin.scripting.compiler.plugin.runWithKotlinc
import org.junit.Ignore
import org.junit.Test import org.junit.Test
import java.io.File import java.io.File
@@ -18,6 +19,15 @@ class MainKtsIT {
runWithKotlincAndMainKts("$TEST_DATA_ROOT/hello-resolve-junit.main.kts", listOf("Hello, World!")) runWithKotlincAndMainKts("$TEST_DATA_ROOT/hello-resolve-junit.main.kts", listOf("Hello, World!"))
} }
@Test
@Ignore // Fails on TC most likely due to repo proxying
fun testKotlinxHtml() {
runWithK2JVMCompilerAndMainKts(
"$TEST_DATA_ROOT/kotlinx-html.main.kts",
listOf("<html>", " <body>", " <h1>Hello, World!</h1>", " </body>", "</html>")
)
}
@Test @Test
fun testImport() { fun testImport() {
val mainKtsJar = File("dist/kotlinc/lib/kotlin-main-kts.jar") val mainKtsJar = File("dist/kotlinc/lib/kotlin-main-kts.jar")
@@ -49,3 +59,16 @@ fun runWithKotlincAndMainKts(
) )
) )
fun runWithK2JVMCompilerAndMainKts(
scriptPath: String,
expectedOutPatterns: List<String> = emptyList(),
expectedExitCode: Int = 0
) = runWithK2JVMCompiler(
scriptPath, expectedOutPatterns, expectedExitCode,
classpath = listOf(
File("dist/kotlinc/lib/kotlin-main-kts.jar").also {
Assert.assertTrue("kotlin-main-kts.jar not found, run dist task: ${it.absolutePath}", it.exists())
}
)
)
+15
View File
@@ -0,0 +1,15 @@
#!/usr/bin/env kotlinc -cp dist/kotlinc/lib/kotlin-main-kts.jar -script
@file:Repository("https://jcenter.bintray.com")
@file:DependsOn("org.jetbrains.kotlinx:kotlinx-html-jvm:0.6.11")
import kotlinx.html.*; import kotlinx.html.stream.*; import kotlinx.html.attributes.*
BooleanEncoder()
print(createHTML().html {
body {
h1 { +"Hello, World!" }
}
})