Enable K2 scripting tests
This commit is contained in:
committed by
Space Team
parent
266a223460
commit
480ea80fc4
@@ -33,7 +33,10 @@ projectTest(parallel = true) {
|
||||
}
|
||||
|
||||
projectTest(taskName = "testWithK2", parallel = true) {
|
||||
dependsOn(":dist")
|
||||
dependsOn(":dist", ":kotlinx-serialization-compiler-plugin.embeddable:embeddable")
|
||||
workingDir = rootDir
|
||||
systemProperty("kotlin.script.base.compiler.arguments", "-Xuse-k2")
|
||||
val localKotlinxSerializationPluginClasspath: FileCollection = kotlinxSerializationGradlePluginClasspath
|
||||
systemProperty("kotlin.script.test.kotlinx.serialization.plugin.classpath", localKotlinxSerializationPluginClasspath.asPath)
|
||||
systemProperty("kotlin.script.base.compiler.arguments", "-language-version 2.0")
|
||||
systemProperty("kotlin.script.test.base.compiler.arguments", "-language-version 2.0")
|
||||
}
|
||||
|
||||
+8
-9
@@ -7,10 +7,7 @@ package org.jetbrains.kotlin.mainKts.test
|
||||
|
||||
import org.jetbrains.kotlin.mainKts.COMPILED_SCRIPTS_CACHE_DIR_ENV_VAR
|
||||
import org.jetbrains.kotlin.mainKts.COMPILED_SCRIPTS_CACHE_DIR_PROPERTY
|
||||
import org.jetbrains.kotlin.scripting.compiler.plugin.runAndCheckResults
|
||||
import org.jetbrains.kotlin.scripting.compiler.plugin.runWithK2JVMCompiler
|
||||
import org.jetbrains.kotlin.scripting.compiler.plugin.runWithKotlinLauncherScript
|
||||
import org.jetbrains.kotlin.scripting.compiler.plugin.runWithKotlinc
|
||||
import org.jetbrains.kotlin.scripting.compiler.plugin.*
|
||||
import org.jetbrains.kotlin.utils.KotlinPaths
|
||||
import org.jetbrains.kotlin.utils.PathUtil
|
||||
import org.junit.Assert
|
||||
@@ -69,7 +66,7 @@ class MainKtsIT {
|
||||
|
||||
@OptIn(ExperimentalPathApi::class)
|
||||
@Test
|
||||
fun testCache() {
|
||||
fun testCache() = expectTestToFailOnK2 {
|
||||
val script = File("$TEST_DATA_ROOT/import-test.main.kts").absolutePath
|
||||
val cache = createTempDirectory("main.kts.test")
|
||||
|
||||
@@ -96,7 +93,7 @@ class MainKtsIT {
|
||||
|
||||
@OptIn(ExperimentalPathApi::class)
|
||||
@Test
|
||||
fun testCacheInProcess() {
|
||||
fun testCacheInProcess() = expectTestToFailOnK2 {
|
||||
val script = File("$TEST_DATA_ROOT/import-test.main.kts").absolutePath
|
||||
val cache = createTempDirectory("main.kts.test")
|
||||
|
||||
@@ -123,7 +120,7 @@ class MainKtsIT {
|
||||
|
||||
@OptIn(ExperimentalPathApi::class)
|
||||
@Test
|
||||
fun testCacheWithFileLocation() {
|
||||
fun testCacheWithFileLocation() = expectTestToFailOnK2 {
|
||||
val scriptPath = File("$TEST_DATA_ROOT/script-file-location-default.main.kts").absolutePath
|
||||
val cache = createTempDirectory("main.kts.test")
|
||||
val expectedTestOutput = listOf(Regex.escape(scriptPath))
|
||||
@@ -185,11 +182,13 @@ fun runWithKotlinRunner(
|
||||
scriptPath: String,
|
||||
expectedOutPatterns: List<String> = emptyList(),
|
||||
expectedExitCode: Int = 0,
|
||||
cacheDir: Path? = null
|
||||
cacheDir: Path? = null,
|
||||
expectErrorOnK2: Boolean = false
|
||||
) {
|
||||
runWithKotlinLauncherScript(
|
||||
"kotlin", listOf(scriptPath), expectedOutPatterns, expectedExitCode,
|
||||
additionalEnvVars = listOf(COMPILED_SCRIPTS_CACHE_DIR_ENV_VAR to (cacheDir?.toAbsolutePath()?.toString() ?: ""))
|
||||
additionalEnvVars = listOf(COMPILED_SCRIPTS_CACHE_DIR_ENV_VAR to (cacheDir?.toAbsolutePath()?.toString() ?: "")),
|
||||
expectErrorOnK2 = expectErrorOnK2
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
+7
-6
@@ -9,6 +9,7 @@ import org.jetbrains.kotlin.mainKts.MainKtsScript
|
||||
import org.jetbrains.kotlin.mainKts.SCRIPT_FILE_LOCATION_DEFAULT_VARIABLE_NAME
|
||||
import org.jetbrains.kotlin.mainKts.impl.Directories
|
||||
import org.jetbrains.kotlin.scripting.compiler.plugin.assertTrue
|
||||
import org.jetbrains.kotlin.scripting.compiler.plugin.expectTestToFailOnK2
|
||||
import org.junit.Assert
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Ignore
|
||||
@@ -77,7 +78,7 @@ class MainKtsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testResolveRuntimeDeps() {
|
||||
fun testResolveRuntimeDeps() = expectTestToFailOnK2 {
|
||||
val resOk = evalFile(File("$TEST_DATA_ROOT/resolve-with-runtime.main.kts"))
|
||||
assertSucceeded(resOk)
|
||||
|
||||
@@ -125,7 +126,7 @@ class MainKtsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testImport() {
|
||||
fun testImport() = expectTestToFailOnK2 {
|
||||
|
||||
val out = captureOut {
|
||||
val res = evalFile(File("$TEST_DATA_ROOT/import-test.main.kts"))
|
||||
@@ -136,7 +137,7 @@ class MainKtsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testImportWithCapture() {
|
||||
fun testImportWithCapture() = expectTestToFailOnK2 {
|
||||
|
||||
val out = captureOut {
|
||||
val res = evalFile(File("$TEST_DATA_ROOT/import-with-capture-test.main.kts"))
|
||||
@@ -178,7 +179,7 @@ class MainKtsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testScriptFileLocationDefaultVariable() {
|
||||
fun testScriptFileLocationDefaultVariable() = expectTestToFailOnK2 {
|
||||
val resOk = evalFile(File("$TEST_DATA_ROOT/script-file-location-default.main.kts"))
|
||||
assertSucceeded(resOk)
|
||||
val resultValue = resOk.valueOrThrow().returnValue
|
||||
@@ -191,7 +192,7 @@ class MainKtsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testScriptFileLocationCustomizedVariable() {
|
||||
fun testScriptFileLocationCustomizedVariable() = expectTestToFailOnK2 {
|
||||
val resOk = evalFile(File("$TEST_DATA_ROOT/script-file-location-customized.main.kts"))
|
||||
assertSucceeded(resOk)
|
||||
val resultValue = resOk.valueOrThrow().returnValue
|
||||
@@ -204,7 +205,7 @@ class MainKtsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testScriptFileLocationWithImportedScript() {
|
||||
fun testScriptFileLocationWithImportedScript() = expectTestToFailOnK2 {
|
||||
val resOk = evalFile(File("$TEST_DATA_ROOT/script-file-location-with-imported-file.main.kts"))
|
||||
assertSucceeded(resOk)
|
||||
val resultValue = resOk.valueOrThrow().returnValue
|
||||
|
||||
Reference in New Issue
Block a user