提交 95035b3d 编写于 作者: I Ilya Chernikov

Fix various tests

上级 98413f20
......@@ -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 {
......
......@@ -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<JavaPluginConvention>().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()
......
......@@ -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")
......
......@@ -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"))
......
......@@ -884,11 +884,15 @@ open class TestKotlinScriptDummyDependenciesResolver : DependenciesResolver {
@ScriptTemplateDefinition(resolver = TestKotlinScriptDummyDependenciesResolver::class)
abstract class ScriptWithNoParam
internal fun classpathFromClassloader(): List<File> =
(TestKotlinScriptDummyDependenciesResolver::class.java.classLoader as? URLClassLoader)?.urLs
?.mapNotNull(URL::toFile)
?.filter { it.path.contains("out") && it.path.contains("test") }
?: emptyList()
internal fun classpathFromClassloader(): List<File> {
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 {
......
......@@ -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)
......
......@@ -8,7 +8,7 @@ jvmTarget = "1.6"
javaHome = rootProject.extra["JDK_16"] as String
dependencies {
compile(projectDist(":kotlin-stdlib"))
compileOnly(projectDist(":kotlin-stdlib"))
}
sourceSets {
......
......@@ -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 {
......
......@@ -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"))
......
......@@ -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"))
......
......@@ -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 {
......
......@@ -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
......@@ -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<File> =
(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()
......
......@@ -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"))
......
......@@ -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"))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册