Restore script testing on both backends, fix some tests
This commit is contained in:
committed by
TeamCityServer
parent
670575696f
commit
ec2d6ea5f1
@@ -43,6 +43,7 @@ tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>> {
|
||||
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
|
||||
|
||||
+4
-1
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
+20
-4
@@ -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<EvaluationResult>) {
|
||||
assertFailedAny(expectedError, res = res)
|
||||
}
|
||||
|
||||
private fun assertFailedAny(vararg expectedErrors: String, res: ResultWithDiagnostics<EvaluationResult>) {
|
||||
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) } }
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user