From 95035b3d72281e6cab000ae6c3ff9488c58ebd3d Mon Sep 17 00:00:00 2001 From: Ilya Chernikov Date: Mon, 4 Sep 2017 11:03:55 +0300 Subject: [PATCH] Fix various tests --- build.gradle.kts | 30 +++++++++++++++---- buildSrc/src/main/kotlin/tasks.kt | 3 ++ compiler/build.gradle.kts | 1 + compiler/container/build.gradle.kts | 2 ++ .../kotlin/daemon/CompilerDaemonTest.kt | 14 +++++---- .../kotlin/scripts/ScriptTemplateTest.kt | 4 +-- core/util.runtime/build.gradle.kts | 2 +- idea/idea-gradle/build.gradle.kts | 21 ++++++++++++- idea/idea-maven/build.gradle.kts | 7 +++++ j2k/build.gradle.kts | 1 + libraries/stdlib/js/build.gradle | 7 +++-- .../build.gradle | 6 ++++ .../CasesPublicAPITest.kt | 13 +++++--- .../android-extensions-idea/build.gradle.kts | 1 + prepare/compiler/build.gradle.kts | 1 + 15 files changed, 92 insertions(+), 21 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 2e8ac1e59dd..859ec883cd0 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -69,12 +69,14 @@ val distDir = "$rootDir/dist" val distKotlinHomeDir = "$distDir/kotlinc" val distLibDir = "$distKotlinHomeDir/lib" val ideaPluginDir = "$distDir/artifacts/Kotlin" +val ideaUltimatePluginDir = "$distDir/artifacts/KotlinUltimate" extra["distDir"] = distDir extra["distKotlinHomeDir"] = distKotlinHomeDir extra["distLibDir"] = project.file(distLibDir) extra["libsDir"] = project.file(distLibDir) extra["ideaPluginDir"] = project.file(ideaPluginDir) +extra["ideaUltimatePluginDir"] = project.file(ideaUltimatePluginDir) extra["isSonatypeRelease"] = false Properties().apply { @@ -247,36 +249,44 @@ tasks { dependsOn(":kotlin-test:kotlin-test-common:test", ":kotlin-test:kotlin-test-jvm:test", ":kotlin-test:kotlin-test-junit:test", -// ":kotlin-test:kotlin-test-js:test", ":kotlin-stdlib:test", ":kotlin-stdlib-jre7:test", ":kotlin-stdlib-jre8:test", -// ":kotlin-stdlib-js:test", -// ":tools:binary-compatibility-validator:test", + ":tools:binary-compatibility-validator:test", ":kotlin-reflect:test") } + "core-libs-check" { dependsOn("core-libs-tests") } "compiler-tests" { - dependsOn("dist") + afterEvaluate { + dependsOn("dist") + } dependsOn(":compiler:test", ":compiler:container:test", ":compiler:tests-java8:test") } + "compiler-check" { dependsOn("compiler-tests") } "js-tests" { dependsOn("dist") - dependsOn(":js:js.tests:test") + dependsOn( + ":kotlin-test:kotlin-test-js:test", + ":kotlin-stdlib-js:test", + ":js:js.tests:test") } + "js-check" { dependsOn("js-tests") } "jps-tests" { dependsOn("dist") dependsOn(":jps-plugin:test") } + "check" { dependsOn("test") } "idea-plugin-main-tests" { dependsOn("dist") dependsOn(":idea:test") } + "idea-plugin-main-check" { dependsOn("idea-plugin-main-tests") } "idea-plugin-additional-tests" { dependsOn("dist") @@ -285,11 +295,14 @@ tasks { ":j2k:test", ":eval4j:test") } + "idea-plugin-additional-check" { dependsOn("idea-plugin-additional-tests") } + "idea-plugin-tests" { dependsOn("dist") dependsOn("idea-plugin-main-tests", "idea-plugin-additional-tests") } + "idea-plugin-check" { dependsOn("idea-plugin-tests") } "android-tests" { dependsOn("dist") @@ -298,6 +311,7 @@ tasks { ":kotlin-annotation-processing:test", ":compiler:android-tests:test") } + "android-check" { dependsOn("android-tests") } "plugins-tests" { dependsOn("dist") @@ -307,6 +321,7 @@ tasks { ":plugins:uast-kotlin:test", ":kotlin-annotation-processing-gradle:test") } + "plugins-check" { dependsOn("plugins-tests") } "scripting-tests" { dependsOn("dist") @@ -314,18 +329,21 @@ tasks { ":examples:kotlin-jsr223-local-example:test", ":examples:kotlin-jsr223-daemon-local-eval-example:test") } + "scripting-check" { dependsOn("scripting-tests") } "other-tests" { dependsOn("dist") dependsOn(":kotlin-build-common:test", ":generators:test") } + "other-check" { dependsOn("other-tests") } "test" { doLast { - throw GradleException("Don't use directly, use aggregate tasks *-tests instead") + throw GradleException("Don't use directly, use aggregate tasks *-check instead") } } + "check" { dependsOn("test") } } fun jdkPath(version: String): String { diff --git a/buildSrc/src/main/kotlin/tasks.kt b/buildSrc/src/main/kotlin/tasks.kt index f2f4b57f320..7495e190ecc 100644 --- a/buildSrc/src/main/kotlin/tasks.kt +++ b/buildSrc/src/main/kotlin/tasks.kt @@ -2,6 +2,7 @@ import org.gradle.api.* import org.gradle.api.internal.tasks.testing.filter.DefaultTestFilter +import org.gradle.api.plugins.JavaPluginConvention import org.gradle.kotlin.dsl.* import org.gradle.api.tasks.testing.Test import org.gradle.kotlin.dsl.extra @@ -33,6 +34,8 @@ fun Project.projectTest(body: Test.() -> Unit = {}): Test = (tasks.findByName("t 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"]) ignoreFailures = System.getenv("kotlin_build_ignore_test_failures")?.let { it == "yes" } ?: false body() diff --git a/compiler/build.gradle.kts b/compiler/build.gradle.kts index 5777bd75606..d6325515ac2 100644 --- a/compiler/build.gradle.kts +++ b/compiler/build.gradle.kts @@ -30,6 +30,7 @@ val testDistProjects = listOf( ":kotlin-test:kotlin-test-junit", ":kotlin-test:kotlin-test-js", ":kotlin-daemon-client", + ":kotlin-preloader", ":android-extensions-compiler", ":kotlin-ant") diff --git a/compiler/container/build.gradle.kts b/compiler/container/build.gradle.kts index ab4ea654fd7..0dfded4c2f4 100644 --- a/compiler/container/build.gradle.kts +++ b/compiler/container/build.gradle.kts @@ -7,6 +7,8 @@ dependencies { compile(project(":core:util.runtime")) compile(commonDep("javax.inject")) compile(ideaSdkCoreDeps("intellij-core")) + compileOnly(project(":kotlin-stdlib")) + testCompile(project(":kotlin-stdlib")) testCompile(projectDist(":kotlin-test:kotlin-test-jvm")) testCompile(projectDist(":kotlin-test:kotlin-test-junit")) testCompile(commonDep("junit:junit")) diff --git a/compiler/tests/org/jetbrains/kotlin/daemon/CompilerDaemonTest.kt b/compiler/tests/org/jetbrains/kotlin/daemon/CompilerDaemonTest.kt index 8ebb900c33b..33d9db5d1b3 100644 --- a/compiler/tests/org/jetbrains/kotlin/daemon/CompilerDaemonTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/daemon/CompilerDaemonTest.kt @@ -884,11 +884,15 @@ open class TestKotlinScriptDummyDependenciesResolver : DependenciesResolver { @ScriptTemplateDefinition(resolver = TestKotlinScriptDummyDependenciesResolver::class) abstract class ScriptWithNoParam -internal fun classpathFromClassloader(): List = - (TestKotlinScriptDummyDependenciesResolver::class.java.classLoader as? URLClassLoader)?.urLs - ?.mapNotNull(URL::toFile) - ?.filter { it.path.contains("out") && it.path.contains("test") } - ?: emptyList() +internal fun classpathFromClassloader(): List { + val additionalClasspath = System.getProperty("kotlin.test.script.classpath")?.split(File.pathSeparator) + ?.map{ File(it) }.orEmpty() + return ((TestKotlinScriptDummyDependenciesResolver::class.java.classLoader as? URLClassLoader)?.urLs + ?.mapNotNull(URL::toFile) + ?.filter { it.path.contains("out") && it.path.contains("test") } + ?: emptyList() + ) + additionalClasspath +} internal fun URL.toFile() = try { diff --git a/compiler/tests/org/jetbrains/kotlin/scripts/ScriptTemplateTest.kt b/compiler/tests/org/jetbrains/kotlin/scripts/ScriptTemplateTest.kt index 99aec173a81..78b50f664aa 100644 --- a/compiler/tests/org/jetbrains/kotlin/scripts/ScriptTemplateTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/scripts/ScriptTemplateTest.kt @@ -97,7 +97,7 @@ class ScriptTemplateTest { Assert.assertNull(compileScript("fib_ext_ann.kts", ScriptWithIntParamAndDummyResolver::class, null, includeKotlinRuntime = false)) val messageCollector = TestMessageCollector() - val aClass = compileScript("fib_ext_ann.kts", ScriptWithIntParam::class, null, includeKotlinRuntime = false, messageCollector = messageCollector) + val aClass = compileScript("fib_ext_ann.kts", ScriptWithIntParam::class, null, messageCollector = messageCollector) Assert.assertNotNull("Compilation failed:\n$messageCollector", aClass) val out = captureOut { aClass!!.getConstructor(Integer.TYPE).newInstance(4) @@ -117,7 +117,7 @@ class ScriptTemplateTest { } val messageCollector = TestMessageCollector() - val aClass = compileScript("fib_ext_ann2.kts", ScriptWithIntParam::class, null, includeKotlinRuntime = false, messageCollector = messageCollector) + val aClass = compileScript("fib_ext_ann2.kts", ScriptWithIntParam::class, null, messageCollector = messageCollector) Assert.assertNotNull("Compilation failed:\n$messageCollector", aClass) val out = captureOut { aClass!!.getConstructor(Integer.TYPE).newInstance(4) diff --git a/core/util.runtime/build.gradle.kts b/core/util.runtime/build.gradle.kts index ac8320b2d0d..9cd37dca39e 100644 --- a/core/util.runtime/build.gradle.kts +++ b/core/util.runtime/build.gradle.kts @@ -8,7 +8,7 @@ jvmTarget = "1.6" javaHome = rootProject.extra["JDK_16"] as String dependencies { - compile(projectDist(":kotlin-stdlib")) + compileOnly(projectDist(":kotlin-stdlib")) } sourceSets { diff --git a/idea/idea-gradle/build.gradle.kts b/idea/idea-gradle/build.gradle.kts index 13b539a71dd..db7e35aa446 100644 --- a/idea/idea-gradle/build.gradle.kts +++ b/idea/idea-gradle/build.gradle.kts @@ -18,9 +18,28 @@ dependencies { testCompile(projectTests(":idea")) testCompile(project(":idea:idea-test-framework")) - testCompile(ideaSdkDeps("openapi", "idea", "groovy-all")) testCompile(ideaPluginDeps("gradle-wrapper", "gradle-base-services", "gradle-tooling-extension-impl", "gradle-tooling-api", "gradle", plugin = "gradle")) testCompile(ideaPluginDeps("Groovy", plugin = "Groovy")) + testCompile(ideaSdkDeps("groovy-all")) + + testRuntime(project(":idea:idea-jvm")) + testRuntime(project(":idea:idea-android")) + testRuntime(project(":plugins:android-extensions-idea")) + testRuntime(project(":plugins:lint")) + testRuntime(project(":sam-with-receiver-ide-plugin")) + testRuntime(project(":allopen-ide-plugin")) + testRuntime(project(":noarg-ide-plugin")) + + testRuntime(ideaSdkDeps("*.jar")) + + testRuntime(ideaPluginDeps("*.jar", plugin = "junit")) + testRuntime(ideaPluginDeps("jcommander", "resources_en", plugin = "testng")) + testRuntime(ideaPluginDeps("resources_en", plugin = "properties")) + testRuntime(ideaPluginDeps("*.jar", plugin = "gradle")) + testRuntime(ideaPluginDeps("*.jar", plugin = "Groovy")) + testRuntime(ideaPluginDeps("jacocoant", plugin = "coverage")) + testRuntime(ideaPluginDeps("*.jar", plugin = "maven")) + testRuntime(ideaPluginDeps("*.jar", plugin = "android")) } sourceSets { diff --git a/idea/idea-maven/build.gradle.kts b/idea/idea-maven/build.gradle.kts index 54dd95b7b24..66ea0a75f8b 100644 --- a/idea/idea-maven/build.gradle.kts +++ b/idea/idea-maven/build.gradle.kts @@ -23,6 +23,13 @@ dependencies { testCompileOnly(ideaSdkDeps("openapi", "idea", "gson")) testCompileOnly(ideaPluginDeps("maven", "maven-server-api", plugin = "maven")) + testRuntime(project(":idea:idea-jvm")) + testRuntime(project(":idea:idea-android")) + testRuntime(project(":plugins:android-extensions-idea")) + testRuntime(project(":plugins:lint")) + testRuntime(project(":sam-with-receiver-ide-plugin")) + testRuntime(project(":allopen-ide-plugin")) + testRuntime(project(":noarg-ide-plugin")) testRuntime(ideaSdkDeps("*.jar")) testRuntime(ideaPluginDeps("resources_en", plugin = "junit")) testRuntime(ideaPluginDeps("jcommander", "resources_en", plugin = "testng")) diff --git a/j2k/build.gradle.kts b/j2k/build.gradle.kts index b2d9cecea80..163a91d2563 100644 --- a/j2k/build.gradle.kts +++ b/j2k/build.gradle.kts @@ -18,6 +18,7 @@ dependencies { testCompile(projectDist(":kotlin-test:kotlin-test-junit")) testCompile(commonDep("junit:junit")) testCompile(project(":compiler.tests-common")) + testRuntime(project(":idea:idea-jvm")) testRuntime(project(":idea:idea-android")) testRuntime(project(":plugins:android-extensions-idea")) testRuntime(project(":sam-with-receiver-ide-plugin")) diff --git a/libraries/stdlib/js/build.gradle b/libraries/stdlib/js/build.gradle index fad1bc21249..deca9178360 100644 --- a/libraries/stdlib/js/build.gradle +++ b/libraries/stdlib/js/build.gradle @@ -19,9 +19,12 @@ def jsSrcDir = "${jsLibrariesDir}/src" def jsTestSrcDir = "${jsLibrariesDir}/test" def jsSrcJsDir = "${jsSrcDir}/js" def jsOutputFile = "${buildDir}/classes/kotlin.js" -def jsTestOutputFile = "${buildDir}/classes/test/kotlin-stdlib-js_test.js" + def kotlinTestJsOutputFile = "${project(':kotlin-test:kotlin-test-js').buildDir}/classes/main/kotlin-test.js" -def kotlinTestJsTestOutputFile = "${project(':kotlin-test:kotlin-test-js').buildDir}/classes/test/kotlin-test-js_test.js" + +// TODO: take from sourcesets' outputs +def jsTestOutputFile = "${buildDir}/classes/kotlin/test/kotlin-stdlib-js_test.js" +def kotlinTestJsTestOutputFile = "${project(':kotlin-test:kotlin-test-js').buildDir}/classes/kotlin/test/kotlin-test-js_test.js" sourceSets { diff --git a/libraries/tools/binary-compatibility-validator/build.gradle b/libraries/tools/binary-compatibility-validator/build.gradle index ee17e7e3e42..7df2fab1764 100644 --- a/libraries/tools/binary-compatibility-validator/build.gradle +++ b/libraries/tools/binary-compatibility-validator/build.gradle @@ -40,4 +40,10 @@ test { systemProperty 'overwrite.output', System.getProperty("overwrite.output", "false") systemProperty 'kotlinVersion', project.version jvmArgs '-ea' + + ignoreFailures = System.getenv("kotlin_build_ignore_test_failures") == 'yes' + environment("PROJECT_CLASSES_DIRS", sourceSets.test.output.classesDirs.asPath) + environment("PROJECT_BUILD_DIR", buildDir) + + workingDir = projectDir } \ No newline at end of file diff --git a/libraries/tools/binary-compatibility-validator/src/test/kotlin/org.jetbrains.kotlin.tools.tests/CasesPublicAPITest.kt b/libraries/tools/binary-compatibility-validator/src/test/kotlin/org.jetbrains.kotlin.tools.tests/CasesPublicAPITest.kt index fc9c51bf334..c1acfb9d2ef 100644 --- a/libraries/tools/binary-compatibility-validator/src/test/kotlin/org.jetbrains.kotlin.tools.tests/CasesPublicAPITest.kt +++ b/libraries/tools/binary-compatibility-validator/src/test/kotlin/org.jetbrains.kotlin.tools.tests/CasesPublicAPITest.kt @@ -8,8 +8,13 @@ import java.io.File class CasesPublicAPITest { companion object { - val visibilities by lazy { readKotlinVisibilities(File("build/cases-declarations.json")) } - val baseClassPath = File("build/classes/test/cases").absoluteFile + val visibilities by lazy { readKotlinVisibilities(File(System.getenv("PROJECT_BUILD_DIR") ?: "build", "cases-declarations.json")) } + val baseClassPaths: List = + (System.getenv("PROJECT_CLASSES_DIRS")?.let { it.split(File.pathSeparator) } + ?: listOf("build/classes/kotlin/test/cases", "build/classes/java/test/cases")) + .mapNotNull { File(it, "cases").canonicalFile.takeIf { it.isDirectory } } + .takeIf { it.isNotEmpty() } + ?: throw IllegalStateException("Unable to get classes output dirs, set PROJECT_CLASSES_DIRS environment variable") val baseOutputPath = File("src/test/kotlin/cases") } @@ -42,8 +47,8 @@ class CasesPublicAPITest { private fun snapshotAPIAndCompare(testClassRelativePath: String) { - val testClassPath = baseClassPath.resolve(testClassRelativePath) - val testClasses = testClassPath.listFiles() ?: throw IllegalStateException("Cannot list files in $testClassPath") + val testClassPaths = baseClassPaths.map { it.resolve(testClassRelativePath) } + val testClasses = testClassPaths.flatMap { it.listFiles()?.asIterable() ?: emptyList() } val testClassStreams = testClasses.asSequence().filter { it.name.endsWith(".class") }.map { it.inputStream() } val api = getBinaryAPI(testClassStreams, visibilities).filterOutNonPublic() diff --git a/plugins/android-extensions/android-extensions-idea/build.gradle.kts b/plugins/android-extensions/android-extensions-idea/build.gradle.kts index f5d5e93bab2..ff7dd9bae21 100644 --- a/plugins/android-extensions/android-extensions-idea/build.gradle.kts +++ b/plugins/android-extensions/android-extensions-idea/build.gradle.kts @@ -20,6 +20,7 @@ dependencies { testCompile(projectTests(":idea:idea-android")) testCompile(projectDist(":kotlin-test:kotlin-test-jvm")) testCompile(commonDep("junit:junit")) + testRuntime(project(":idea:idea-jvm")) testRuntime(project(":plugins:android-extensions-jps")) testRuntime(project(":sam-with-receiver-ide-plugin")) testRuntime(project(":noarg-ide-plugin")) diff --git a/prepare/compiler/build.gradle.kts b/prepare/compiler/build.gradle.kts index 1a554ff0b72..7b3b8e01807 100644 --- a/prepare/compiler/build.gradle.kts +++ b/prepare/compiler/build.gradle.kts @@ -75,6 +75,7 @@ dependencies { fatJarContents(ideaSdkDeps("jna-platform")) fatJarContents(commonDep("javax.inject")) fatJarContents(commonDep("org.jline", "jline")) + fatJarContents(commonDep("org.fusesource.jansi", "jansi")) fatJarContents(protobufFull()) fatJarContents(commonDep("com.github.spullara.cli-parser", "cli-parser")) fatJarContents(commonDep("com.google.code.findbugs", "jsr305"))