Fix script util tests after moving context utils to scripting-jvm

This commit is contained in:
Ilya Chernikov
2018-09-16 22:24:59 +02:00
parent 94e6f986e7
commit 73907106e9
2 changed files with 1 additions and 51 deletions
@@ -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)
}
}
@@ -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<String>::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<String>::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)
}