From 2fc8f5d5e2a49e77b911867fcbf8585c3ed2c85f Mon Sep 17 00:00:00 2001 From: Mikhail Zarechenskiy Date: Thu, 15 Sep 2016 14:14:13 +0300 Subject: [PATCH] Move util function closer to its usage and remove empty file --- .../kotlin/scripts/TestScriptDefinitions.kt | 30 ------------------- .../jetbrains/kotlin/scripts/ScriptTest2.kt | 11 +++++++ 2 files changed, 11 insertions(+), 30 deletions(-) delete mode 100644 compiler/tests-common/org/jetbrains/kotlin/scripts/TestScriptDefinitions.kt diff --git a/compiler/tests-common/org/jetbrains/kotlin/scripts/TestScriptDefinitions.kt b/compiler/tests-common/org/jetbrains/kotlin/scripts/TestScriptDefinitions.kt deleted file mode 100644 index 318f2d3dd47..00000000000 --- a/compiler/tests-common/org/jetbrains/kotlin/scripts/TestScriptDefinitions.kt +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2010-2016 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.scripts - -import java.io.File -import java.net.URL -import java.net.URLClassLoader - -fun URL.toFile() = - try { - File(toURI().schemeSpecificPart) - } - catch (e: java.net.URISyntaxException) { - if (protocol != "file") null - else File(file) - } \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/scripts/ScriptTest2.kt b/compiler/tests/org/jetbrains/kotlin/scripts/ScriptTest2.kt index 78ad6f21fd8..8cc800b513d 100644 --- a/compiler/tests/org/jetbrains/kotlin/scripts/ScriptTest2.kt +++ b/compiler/tests/org/jetbrains/kotlin/scripts/ScriptTest2.kt @@ -35,6 +35,8 @@ import org.junit.Test import java.io.File import java.lang.Exception import java.lang.reflect.InvocationTargetException +import java.net.URISyntaxException +import java.net.URL import java.net.URLClassLoader import java.util.concurrent.Future import kotlin.reflect.KClass @@ -258,6 +260,15 @@ class TestKotlinScriptDependenciesResolver : ScriptDependenciesResolver { ?.mapNotNull { it.toFile() } ?.filter { it.path.contains("out") && it.path.contains("test") } ?: emptyList() + + private fun URL.toFile() = + try { + File(toURI().schemeSpecificPart) + } + catch (e: URISyntaxException) { + if (protocol != "file") null + else File(file) + } } @ScriptTemplateDefinition(