Implement test for #KT-29301, #KT-29296 and #KT-29293
This commit is contained in:
+15
@@ -13,13 +13,18 @@ import java.io.PrintStream
|
||||
import kotlin.script.experimental.api.*
|
||||
import kotlin.script.experimental.host.toScriptSource
|
||||
import kotlin.script.experimental.jvmhost.BasicJvmScriptingHost
|
||||
import kotlin.script.experimental.jvmhost.baseClassLoader
|
||||
import kotlin.script.experimental.jvmhost.createJvmCompilationConfigurationFromTemplate
|
||||
import kotlin.script.experimental.jvmhost.jvm
|
||||
|
||||
fun evalFile(scriptFile: File): ResultWithDiagnostics<EvaluationResult> {
|
||||
|
||||
val scriptDefinition = createJvmCompilationConfigurationFromTemplate<MainKtsScript>()
|
||||
|
||||
val evaluationEnv = ScriptEvaluationConfiguration {
|
||||
jvm {
|
||||
baseClassLoader(null)
|
||||
}
|
||||
constructorArgs(emptyArray<String>())
|
||||
enableScriptsInstancesSharing()
|
||||
}
|
||||
@@ -61,6 +66,16 @@ class MainKtsTest {
|
||||
res is ResultWithDiagnostics.Failure && res.reports.any { it.message.contains("Unknown set of arguments to maven resolver: abracadabra") })
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testResolveLog4jAndDocopt() {
|
||||
val res = evalFile(File("testData/resolve-log4j-and-docopt.main.kts"))
|
||||
|
||||
Assert.assertTrue(
|
||||
"test failed:\n ${res.reports.joinToString("\n ") { it.message + if (it.exception == null) "" else ": ${it.exception}" }}",
|
||||
res is ResultWithDiagnostics.Success
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testImport() {
|
||||
|
||||
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
|
||||
// NOTE: copied for kscript tests
|
||||
|
||||
@file:DependsOn("log4j:log4j:1.2.12")
|
||||
@file:DependsOn("com.offbytwo:docopt:0.6.0.20150202")
|
||||
|
||||
// some pointless comment
|
||||
|
||||
import org.docopt.Docopt
|
||||
|
||||
// test the docopt dependency
|
||||
val docopt = Docopt("Usage: jl <command> [options] [<joblist_file>]")
|
||||
|
||||
// instantiate a logger to test the log4j dependency
|
||||
org.apache.log4j.Logger.getRootLogger()
|
||||
|
||||
|
||||
println("Succeeded!")
|
||||
Reference in New Issue
Block a user