diff --git a/libraries/scripting/jvm-host-test/build.gradle.kts b/libraries/scripting/jvm-host-test/build.gradle.kts index 69b1f8a039e..c1c4065fe8c 100644 --- a/libraries/scripting/jvm-host-test/build.gradle.kts +++ b/libraries/scripting/jvm-host-test/build.gradle.kts @@ -43,6 +43,7 @@ tasks.withType> { projectTest(parallel = true) { dependsOn(":dist") workingDir = rootDir + systemProperty("kotlin.script.test.base.compiler.arguments", "-Xuse-old-backend") } // This doesn;t work now due to conflicts between embeddable compiler contents and intellij sdk modules diff --git a/libraries/scripting/jvm-host-test/test/kotlin/script/experimental/jvmhost/test/ImplicitsFromScriptResultTest.kt b/libraries/scripting/jvm-host-test/test/kotlin/script/experimental/jvmhost/test/ImplicitsFromScriptResultTest.kt index 539f63b5d11..a590f0f5a1e 100644 --- a/libraries/scripting/jvm-host-test/test/kotlin/script/experimental/jvmhost/test/ImplicitsFromScriptResultTest.kt +++ b/libraries/scripting/jvm-host-test/test/kotlin/script/experimental/jvmhost/test/ImplicitsFromScriptResultTest.kt @@ -35,7 +35,10 @@ import kotlin.script.experimental.jvmhost.JvmScriptCompiler */ class ImplicitsFromScriptResultTest : TestCase() { fun testImplicits() { - if (System.getProperty("kotlin.script.base.compiler.arguments")?.contains("-Xuse-ir") != true) { + if (System.getProperty("kotlin.script.base.compiler.arguments")?.let { + !it.contains("-Xuse-ir") || it.contains("-Xuse-old-backend") + } == true + ) { // the implementation of the Compiler Host doesn't work with IR - the inter-script symbol table // should be maintained to make it run (see latest REPL compiler implementations for details // TODO: consider either fix it or rewrite to the REPL compiler diff --git a/libraries/tools/kotlin-main-kts-test/build.gradle.kts b/libraries/tools/kotlin-main-kts-test/build.gradle.kts index e8bfeaef08d..cffd68a0635 100644 --- a/libraries/tools/kotlin-main-kts-test/build.gradle.kts +++ b/libraries/tools/kotlin-main-kts-test/build.gradle.kts @@ -23,6 +23,7 @@ sourceSets { projectTest(parallel = true) { dependsOn(":dist") workingDir = rootDir + systemProperty("kotlin.script.test.base.compiler.arguments", "-Xuse-old-backend") } projectTest(taskName = "testWithIr", parallel = true) { diff --git a/libraries/tools/kotlin-main-kts-test/test/org/jetbrains/kotlin/mainKts/test/mainKtsTest.kt b/libraries/tools/kotlin-main-kts-test/test/org/jetbrains/kotlin/mainKts/test/mainKtsTest.kt index b16ab3a32b6..51254ada2d2 100644 --- a/libraries/tools/kotlin-main-kts-test/test/org/jetbrains/kotlin/mainKts/test/mainKtsTest.kt +++ b/libraries/tools/kotlin-main-kts-test/test/org/jetbrains/kotlin/mainKts/test/mainKtsTest.kt @@ -131,7 +131,8 @@ class MainKtsTest { @Test fun testCyclicImportError() { val res = evalFile(File("$TEST_DATA_ROOT/import-cycle-1.main.kts")) - assertFailed("Unable to handle recursive script dependencies", res) + // TODO: the second error is due to the late cycle detection, see TODO in makeCompiledScript$makeOtherScripts + assertFailedAny("Unable to handle recursive script dependencies", "is already bound", res = res) } @Test @@ -228,11 +229,26 @@ class MainKtsTest { } private fun assertFailed(expectedError: String, res: ResultWithDiagnostics) { + assertFailedAny(expectedError, res = res) + } + + private fun assertFailedAny(vararg expectedErrors: String, res: ResultWithDiagnostics) { + val reports = res.reports.map { diag -> + diag.message + + generateSequence(diag.exception) { it.cause } + .filter { !(it.message != null && diag.message.contains(it.message!!)) } + .joinToString("\n Caused by: ", "\n ") { it.message ?: it.toString() } + } + val expected = when (expectedErrors.size) { + 0 -> "" + 1 -> " with the message \"${expectedErrors[0]}\"" + else -> " with any of the messages: ${expectedErrors.joinToString("\", \"", "\"", "\";")}" + } Assert.assertTrue( - "test failed - expecting a failure with the message \"$expectedError\" but received " + + "test failed - expecting a failure$expected but received " + (if (res is ResultWithDiagnostics.Failure) "failure" else "success") + - ":\n ${res.reports.joinToString("\n ") { it.message + if (it.exception == null) "" else ": ${it.exception}" }}", - res is ResultWithDiagnostics.Failure && res.reports.any { it.message.contains("$expectedError") } + ":\n ${reports.joinToString("\n ")}", + res is ResultWithDiagnostics.Failure && reports.any { report -> expectedErrors.any { report.contains(it) } } ) } diff --git a/plugins/scripting/scripting-compiler/build.gradle.kts b/plugins/scripting/scripting-compiler/build.gradle.kts index 2265870ad60..9dc6c32483e 100644 --- a/plugins/scripting/scripting-compiler/build.gradle.kts +++ b/plugins/scripting/scripting-compiler/build.gradle.kts @@ -64,6 +64,7 @@ projectTest(parallel = true) { dependsOn(":dist") workingDir = rootDir systemProperty("kotlin.test.script.classpath", testSourceSet.output.classesDirs.joinToString(File.pathSeparator)) + systemProperty("kotlin.script.test.base.compiler.arguments", "-Xuse-old-backend") } projectTest(taskName = "testWithIr", parallel = true) {