Fix scripting-compiler tests, add them to the global scriptingTest task
This commit is contained in:
@@ -532,6 +532,7 @@ tasks {
|
|||||||
create("scriptingTest") {
|
create("scriptingTest") {
|
||||||
dependsOn("dist")
|
dependsOn("dist")
|
||||||
dependsOn(":kotlin-script-util:test")
|
dependsOn(":kotlin-script-util:test")
|
||||||
|
dependsOn(":kotlin-scripting-compiler:test")
|
||||||
dependsOn(":kotlin-scripting-jvm-host-test:test")
|
dependsOn(":kotlin-scripting-jvm-host-test:test")
|
||||||
dependsOn(":kotlin-scripting-jsr223-test:test")
|
dependsOn(":kotlin-scripting-jsr223-test:test")
|
||||||
dependsOn(":kotlin-scripting-jvm-host-test:embeddableTest")
|
dependsOn(":kotlin-scripting-jvm-host-test:embeddableTest")
|
||||||
|
|||||||
+31
-6
@@ -31,14 +31,22 @@ val ScriptingHostConfigurationKeys.jvm
|
|||||||
|
|
||||||
val defaultJvmScriptingHostConfiguration
|
val defaultJvmScriptingHostConfiguration
|
||||||
get() = ScriptingHostConfiguration {
|
get() = ScriptingHostConfiguration {
|
||||||
getScriptingClass(JvmGetScriptingClass)
|
getScriptingClass(JvmGetScriptingClass())
|
||||||
}
|
}
|
||||||
|
|
||||||
object JvmGetScriptingClass : GetScriptingClass, Serializable {
|
class JvmGetScriptingClass : GetScriptingClass, Serializable {
|
||||||
|
|
||||||
|
@Transient
|
||||||
private var dependencies: List<ScriptDependency>? = null
|
private var dependencies: List<ScriptDependency>? = null
|
||||||
|
|
||||||
|
@Transient
|
||||||
private var classLoader: ClassLoader? = null
|
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
|
private var baseClassLoader: ClassLoader? = null
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
@@ -62,7 +70,7 @@ object JvmGetScriptingClass : GetScriptingClass, Serializable {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!baseClassLoaderIsInitialized) {
|
if (baseClassLoaderIsInitialized != true) {
|
||||||
baseClassLoader = contextClassloader
|
baseClassLoader = contextClassloader
|
||||||
baseClassLoaderIsInitialized = true
|
baseClassLoaderIsInitialized = true
|
||||||
}
|
}
|
||||||
@@ -91,6 +99,23 @@ object JvmGetScriptingClass : GetScriptingClass, Serializable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
override fun equals(other: Any?): Boolean =
|
||||||
private val serialVersionUID = 1L
|
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.SCRIPT_DEFINITION_MARKERS_PATH
|
||||||
import org.jetbrains.kotlin.scripting.definitions.discoverScriptTemplatesInClasspath
|
import org.jetbrains.kotlin.scripting.definitions.discoverScriptTemplatesInClasspath
|
||||||
import org.jetbrains.kotlin.scripting.definitions.loadScriptTemplatesFromClasspath
|
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.ConfigurationKind
|
||||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||||
import org.jetbrains.kotlin.test.TestCaseWithTmpdir
|
import org.jetbrains.kotlin.test.TestCaseWithTmpdir
|
||||||
@@ -115,7 +116,7 @@ class ScriptingCompilerPluginTest : TestCaseWithTmpdir() {
|
|||||||
|
|
||||||
loadScriptTemplatesFromClasspath(
|
loadScriptTemplatesFromClasspath(
|
||||||
listOf("TestScriptWithReceivers", "TestScriptWithSimpleEnvVars"),
|
listOf("TestScriptWithReceivers", "TestScriptWithSimpleEnvVars"),
|
||||||
listOf(defsOut), emptyList(), this::class.java.classLoader, emptyMap(), messageCollector
|
listOf(defsOut), emptyList(), this::class.java.classLoader, emptyMap(), messageCollector.reporter
|
||||||
).toList()
|
).toList()
|
||||||
|
|
||||||
for (def in defClasses) {
|
for (def in defClasses) {
|
||||||
@@ -141,7 +142,7 @@ class ScriptingCompilerPluginTest : TestCaseWithTmpdir() {
|
|||||||
listOf(defsOut),
|
listOf(defsOut),
|
||||||
this::class.java.classLoader,
|
this::class.java.classLoader,
|
||||||
emptyMap(),
|
emptyMap(),
|
||||||
messageCollector
|
messageCollector.reporter
|
||||||
)
|
)
|
||||||
|
|
||||||
assertTrue(messageCollector.messages.isEmpty()) {
|
assertTrue(messageCollector.messages.isEmpty()) {
|
||||||
@@ -212,7 +213,7 @@ class ScriptingCompilerPluginTest : TestCaseWithTmpdir() {
|
|||||||
listOf(defsOut),
|
listOf(defsOut),
|
||||||
this::class.java.classLoader,
|
this::class.java.classLoader,
|
||||||
emptyMap(),
|
emptyMap(),
|
||||||
messageCollector
|
messageCollector.reporter
|
||||||
).toList()
|
).toList()
|
||||||
|
|
||||||
assertTrue(
|
assertTrue(
|
||||||
|
|||||||
Reference in New Issue
Block a user