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
This commit is contained in:
Alexander Udalov
2017-09-18 16:36:41 +03:00
committed by Ilya Chernikov
parent 630d090103
commit 8f5dae8f57
2 changed files with 5 additions and 4 deletions
-1
View File
@@ -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<JavaPluginConvention>().sourceSets.getByName("test").output.classesDirs.asPath)
environment("PROJECT_BUILD_DIR", buildDir)
systemProperty("jps.kotlin.home", rootProject.extra["distKotlinHomeDir"])
@@ -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)