From 8f5dae8f57a05a8c3b178d9bacac53740188797b Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Mon, 18 Sep 2017 16:36:41 +0300 Subject: [PATCH] Do not set KOTLIN_HOME env var for tests Instead, rework the (already suspicious) KotlinPaths-finding code in PathUtil to support the new model of running tests (the compiler is split into several jars according to the project structure) instead of the old one (where class files were not in the jars, but in the out/ directory). This fixes Java9ModulesIntegrationTest --- buildSrc/src/main/kotlin/tasks.kt | 1 - compiler/util/src/org/jetbrains/kotlin/utils/PathUtil.kt | 8 +++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/buildSrc/src/main/kotlin/tasks.kt b/buildSrc/src/main/kotlin/tasks.kt index a2dce631600..cb516a7813b 100644 --- a/buildSrc/src/main/kotlin/tasks.kt +++ b/buildSrc/src/main/kotlin/tasks.kt @@ -33,7 +33,6 @@ fun Project.projectTest(taskName: String = "test", body: Test.() -> Unit = {}): maxHeapSize = "1100m" systemProperty("idea.is.unit.test", "true") environment("NO_FS_ROOTS_ACCESS_CHECK", "true") - environment("KOTLIN_HOME", rootProject.extra["distKotlinHomeDir"]) environment("PROJECT_CLASSES_DIRS", the().sourceSets.getByName("test").output.classesDirs.asPath) environment("PROJECT_BUILD_DIR", buildDir) systemProperty("jps.kotlin.home", rootProject.extra["distKotlinHomeDir"]) diff --git a/compiler/util/src/org/jetbrains/kotlin/utils/PathUtil.kt b/compiler/util/src/org/jetbrains/kotlin/utils/PathUtil.kt index 3a26e53a32d..d017a631349 100644 --- a/compiler/util/src/org/jetbrains/kotlin/utils/PathUtil.kt +++ b/compiler/util/src/org/jetbrains/kotlin/utils/PathUtil.kt @@ -43,7 +43,8 @@ object PathUtil { const val KOTLIN_JAVA_STDLIB_SRC_JAR_OLD = "kotlin-runtime-sources.jar" const val KOTLIN_REFLECT_SRC_JAR = "kotlin-reflect-sources.jar" const val KOTLIN_TEST_SRC_JAR = "kotlin-test-sources.jar" - const val KOTLIN_COMPILER_JAR = "kotlin-compiler.jar" + const val KOTLIN_COMPILER = "kotlin-compiler" + const val KOTLIN_COMPILER_JAR = "$KOTLIN_COMPILER.jar" @JvmField val KOTLIN_RUNTIME_JAR_PATTERN: Pattern = Pattern.compile("kotlin-(stdlib|runtime)(-\\d[\\d.]+(-.+)?)?\\.jar") @@ -63,8 +64,9 @@ object PathUtil { @JvmStatic val kotlinPathsForCompiler: KotlinPaths - get() = if (!pathUtilJar.isFile) { - // Not running from a jar, i.e. it is it must be a unit test + get() = if (!pathUtilJar.isFile || !pathUtilJar.name.startsWith(KOTLIN_COMPILER)) { + // PathUtil.class is located not in the kotlin-compiler*.jar, so it must be a test and we'll take KotlinPaths from "dist/" + // (when running tests, PathUtil.class is in its containing module's artifact, i.e. util-{version}.jar) kotlinPathsForDistDirectory } else KotlinPathsFromHomeDir(compilerPathForCompilerJar)