Fix scripting-compiler tests, add them to the global scriptingTest task
This commit is contained in:
@@ -532,6 +532,7 @@ tasks {
|
||||
create("scriptingTest") {
|
||||
dependsOn("dist")
|
||||
dependsOn(":kotlin-script-util:test")
|
||||
dependsOn(":kotlin-scripting-compiler:test")
|
||||
dependsOn(":kotlin-scripting-jvm-host-test:test")
|
||||
dependsOn(":kotlin-scripting-jsr223-test:test")
|
||||
dependsOn(":kotlin-scripting-jvm-host-test:embeddableTest")
|
||||
|
||||
+31
-6
@@ -31,14 +31,22 @@ val ScriptingHostConfigurationKeys.jvm
|
||||
|
||||
val defaultJvmScriptingHostConfiguration
|
||||
get() = ScriptingHostConfiguration {
|
||||
getScriptingClass(JvmGetScriptingClass)
|
||||
getScriptingClass(JvmGetScriptingClass())
|
||||
}
|
||||
|
||||
object JvmGetScriptingClass : GetScriptingClass, Serializable {
|
||||
class JvmGetScriptingClass : GetScriptingClass, Serializable {
|
||||
|
||||
@Transient
|
||||
private var dependencies: List<ScriptDependency>? = null
|
||||
|
||||
@Transient
|
||||
private var classLoader: ClassLoader? = null
|
||||
private var baseClassLoaderIsInitialized = false
|
||||
|
||||
@Transient
|
||||
// TODO: find out whether Transient fields are initialized on deserialization and if so, convert back to not-nullable val
|
||||
private var baseClassLoaderIsInitialized: Boolean? = null
|
||||
|
||||
@Transient
|
||||
private var baseClassLoader: ClassLoader? = null
|
||||
|
||||
@Synchronized
|
||||
@@ -62,7 +70,7 @@ object JvmGetScriptingClass : GetScriptingClass, Serializable {
|
||||
)
|
||||
}
|
||||
|
||||
if (!baseClassLoaderIsInitialized) {
|
||||
if (baseClassLoaderIsInitialized != true) {
|
||||
baseClassLoader = contextClassloader
|
||||
baseClassLoaderIsInitialized = true
|
||||
}
|
||||
@@ -91,6 +99,23 @@ object JvmGetScriptingClass : GetScriptingClass, Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
private val serialVersionUID = 1L
|
||||
override fun equals(other: Any?): Boolean =
|
||||
when {
|
||||
other === this -> true
|
||||
other !is JvmGetScriptingClass -> false
|
||||
else -> {
|
||||
other.dependencies == dependencies &&
|
||||
(other.classLoader == null || classLoader == null || other.classLoader == classLoader) &&
|
||||
(other.baseClassLoader == null || baseClassLoader == null || other.baseClassLoader == baseClassLoader)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return dependencies.hashCode() + 23 * classLoader.hashCode() + 37 * baseClassLoader.hashCode()
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val serialVersionUID = 1L
|
||||
}
|
||||
}
|
||||
|
||||
+4
-3
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.scripting.configuration.ScriptingConfigurationKeys
|
||||
import org.jetbrains.kotlin.scripting.definitions.SCRIPT_DEFINITION_MARKERS_PATH
|
||||
import org.jetbrains.kotlin.scripting.definitions.discoverScriptTemplatesInClasspath
|
||||
import org.jetbrains.kotlin.scripting.definitions.loadScriptTemplatesFromClasspath
|
||||
import org.jetbrains.kotlin.scripting.definitions.reporter
|
||||
import org.jetbrains.kotlin.test.ConfigurationKind
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import org.jetbrains.kotlin.test.TestCaseWithTmpdir
|
||||
@@ -115,7 +116,7 @@ class ScriptingCompilerPluginTest : TestCaseWithTmpdir() {
|
||||
|
||||
loadScriptTemplatesFromClasspath(
|
||||
listOf("TestScriptWithReceivers", "TestScriptWithSimpleEnvVars"),
|
||||
listOf(defsOut), emptyList(), this::class.java.classLoader, emptyMap(), messageCollector
|
||||
listOf(defsOut), emptyList(), this::class.java.classLoader, emptyMap(), messageCollector.reporter
|
||||
).toList()
|
||||
|
||||
for (def in defClasses) {
|
||||
@@ -141,7 +142,7 @@ class ScriptingCompilerPluginTest : TestCaseWithTmpdir() {
|
||||
listOf(defsOut),
|
||||
this::class.java.classLoader,
|
||||
emptyMap(),
|
||||
messageCollector
|
||||
messageCollector.reporter
|
||||
)
|
||||
|
||||
assertTrue(messageCollector.messages.isEmpty()) {
|
||||
@@ -212,7 +213,7 @@ class ScriptingCompilerPluginTest : TestCaseWithTmpdir() {
|
||||
listOf(defsOut),
|
||||
this::class.java.classLoader,
|
||||
emptyMap(),
|
||||
messageCollector
|
||||
messageCollector.reporter
|
||||
).toList()
|
||||
|
||||
assertTrue(
|
||||
|
||||
Reference in New Issue
Block a user