From 73907106e925f29845ed283cfb148b022749a4f3 Mon Sep 17 00:00:00 2001 From: Ilya Chernikov Date: Sun, 16 Sep 2018 22:24:59 +0200 Subject: [PATCH] Fix script util tests after moving context utils to scripting-jvm --- .../script/util/ScriptUtilContextTests.kt | 44 ------------------- .../kotlin/script/util/ScriptUtilIT.kt | 8 +--- 2 files changed, 1 insertion(+), 51 deletions(-) delete mode 100644 libraries/tools/kotlin-script-util/src/test/kotlin/org/jetbrains/kotlin/script/util/ScriptUtilContextTests.kt diff --git a/libraries/tools/kotlin-script-util/src/test/kotlin/org/jetbrains/kotlin/script/util/ScriptUtilContextTests.kt b/libraries/tools/kotlin-script-util/src/test/kotlin/org/jetbrains/kotlin/script/util/ScriptUtilContextTests.kt deleted file mode 100644 index b2d196304ec..00000000000 --- a/libraries/tools/kotlin-script-util/src/test/kotlin/org/jetbrains/kotlin/script/util/ScriptUtilContextTests.kt +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2010-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.script.util - -import org.junit.Assert -import org.junit.Test - -class ScriptUtilContextTests { - - @Test - fun testExplicitScriptClasspath() { - withSysProp(KOTLIN_SCRIPT_CLASSPATH_PROPERTY, "a:b:c") { - val classpath = scriptCompilationClasspathFromContextOrStlib(wholeClasspath = true) - Assert.assertEquals("a:b:c", classpath.joinToString(":")) - } - } - - // TODO: more tests -} - -private fun withSysProp(name: String, value: String, body: () -> Unit) { - val savedValue = System.setProperty(name, value) - try { - body() - } - finally { - if (savedValue != null) System.setProperty(name, savedValue) - else System.clearProperty(name) - } -} \ No newline at end of file diff --git a/libraries/tools/kotlin-script-util/src/test/kotlin/org/jetbrains/kotlin/script/util/ScriptUtilIT.kt b/libraries/tools/kotlin-script-util/src/test/kotlin/org/jetbrains/kotlin/script/util/ScriptUtilIT.kt index 78175ed3566..73c26641ef7 100644 --- a/libraries/tools/kotlin-script-util/src/test/kotlin/org/jetbrains/kotlin/script/util/ScriptUtilIT.kt +++ b/libraries/tools/kotlin-script-util/src/test/kotlin/org/jetbrains/kotlin/script/util/ScriptUtilIT.kt @@ -98,9 +98,6 @@ done } val scriptClass = compileScript("args-junit-hello-world.kts", StandardArgsScriptTemplateWithMavenResolving::class) - if (scriptClass == null) { - System.err.println(classpathFromClassloader(Thread.currentThread().contextClassLoader)?.takeIfContainsAll(KOTLIN_JAVA_RUNTIME_JAR)?.joinToString()) - } Assert.assertNotNull(scriptClass) captureOut { scriptClass!!.getConstructor(Array::class.java)!!.newInstance(arrayOf("a1")) @@ -112,9 +109,6 @@ done @Test fun testIvyResolveStdJUnitHelloWorld() { val scriptClass = compileScript("args-junit-hello-world.kts", StandardArgsScriptTemplateWithIvyResolving::class) - if (scriptClass == null) { - System.err.println(classpathFromClassloader(Thread.currentThread().contextClassLoader)?.takeIfContainsAll(KOTLIN_JAVA_RUNTIME_JAR)?.joinToString()) - } Assert.assertNotNull(scriptClass) captureOut { scriptClass!!.getConstructor(Array::class.java)!!.newInstance(arrayOf("a1")) @@ -144,7 +138,7 @@ done val rootDisposable = Disposer.newDisposable() try { val configuration = CompilerConfiguration().apply { - classpathFromClassloader(Thread.currentThread().contextClassLoader)?.takeIfContainsAll(KOTLIN_JAVA_RUNTIME_JAR)?.let { + scriptCompilationClasspathFromContextOrNull(KOTLIN_JAVA_RUNTIME_JAR)?.let { addJvmClasspathRoots(it) }