Refactor test utils: don't add main-kts to the classpath...
by default on running scripting tests via the call to K2JVMCompiler
This commit is contained in:
+13
-6
@@ -27,18 +27,25 @@ class ScriptingWithCliCompilerTest {
|
||||
|
||||
@Test
|
||||
fun testStandardScriptWithDeps() {
|
||||
runWithK2JVMCompiler("$TEST_DATA_DIR/integration/withDependencyOnCompileClassPath.kts", listOf("Hello from standard kts!"))
|
||||
runWithK2JVMCompiler(
|
||||
"$TEST_DATA_DIR/integration/withDependencyOnCompileClassPath.kts", listOf("Hello from standard kts!"),
|
||||
classpath = getMainKtsClassPath()
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testStandardScriptWithDepsViaKotlinc() {
|
||||
runWithKotlinc(
|
||||
"$TEST_DATA_DIR/integration/withDependencyOnCompileClassPath.kts", listOf("Hello from standard kts!"),
|
||||
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())
|
||||
}
|
||||
)
|
||||
classpath = getMainKtsClassPath()
|
||||
)
|
||||
}
|
||||
|
||||
private fun getMainKtsClassPath(): List<File> {
|
||||
return 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())
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+11
-5
@@ -98,15 +98,21 @@ fun runWithKotlinc(
|
||||
fun runWithK2JVMCompiler(
|
||||
scriptPath: String,
|
||||
expectedOutPatterns: List<String> = emptyList(),
|
||||
expectedExitCode: Int = 0
|
||||
expectedExitCode: Int = 0,
|
||||
classpath: List<File> = emptyList()
|
||||
) {
|
||||
val mainKtsJar = File("dist/kotlinc/lib/kotlin-main-kts.jar")
|
||||
Assert.assertTrue("kotlin-main-kts.jar not found, run dist task: ${mainKtsJar.absolutePath}", mainKtsJar.exists())
|
||||
|
||||
val args = arrayListOf("-kotlin-home", "dist/kotlinc").apply {
|
||||
if (classpath.isNotEmpty()) {
|
||||
add("-cp")
|
||||
add(classpath.joinToString(File.pathSeparator))
|
||||
}
|
||||
add("-script")
|
||||
add(scriptPath)
|
||||
}
|
||||
val (out, err, ret) = captureOutErrRet {
|
||||
CLITool.doMainNoExit(
|
||||
K2JVMCompiler(),
|
||||
arrayOf("-kotlin-home", "dist/kotlinc", "-cp", mainKtsJar.absolutePath, "-script", scriptPath)
|
||||
args.toTypedArray()
|
||||
)
|
||||
}
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user