Extract jvm6-specific test utils, add codegen on specific jdk tests
This commit is contained in:
@@ -42,6 +42,7 @@ dependencies {
|
||||
testCompileOnly(projectDist(":kotlin-test:kotlin-test-jvm"))
|
||||
testCompileOnly(projectDist(":kotlin-test:kotlin-test-junit"))
|
||||
testCompile(project(":compiler.tests-common"))
|
||||
testCompile(project(":compiler:tests-common-jvm6"))
|
||||
testCompile(project(":compiler:ir.ir2cfg"))
|
||||
testCompile(project(":compiler:ir.tree")) // used for deepCopyWithSymbols call that is removed by proguard from the compiler TODO: make it more straightforward
|
||||
otherCompilerModules.forEach {
|
||||
@@ -79,3 +80,38 @@ projectTest {
|
||||
systemProperty("kotlin.test.script.classpath", the<JavaPluginConvention>().sourceSets.getByName("test").output.classesDirs.joinToString(File.pathSeparator))
|
||||
}
|
||||
|
||||
evaluationDependsOn(":compiler:tests-common-jvm6")
|
||||
|
||||
fun Project.codegenTest(taskName: String, body: Test.() -> Unit): Test = projectTest(taskName) {
|
||||
dependsOn(*testDistProjects.map { "$it:dist" }.toTypedArray())
|
||||
workingDir = rootDir
|
||||
environment("TEST_SERVER_CLASSES_DIRS", project(":compiler:tests-common-jvm6").the<JavaPluginConvention>().sourceSets.getByName("main").output.classesDirs.asPath)
|
||||
filter.includeTestsMatching("org.jetbrains.kotlin.codegen.CodegenJdkCommonTestSuite*")
|
||||
body()
|
||||
}
|
||||
|
||||
codegenTest("codegen-target6-jvm6-test") {
|
||||
systemProperty("kotlin.test.default.jvm.target", "1.6")
|
||||
systemProperty("kotlin.test.java.compilation.target", "1.6")
|
||||
systemProperty("kotlin.test.box.in.separate.process.port", "5100")
|
||||
}
|
||||
|
||||
codegenTest("codegen-target6-jvm9-test") {
|
||||
systemProperty("kotlin.test.default.jvm.target", "1.6")
|
||||
jvmArgs = listOf("--add-opens", "java.desktop/javax.swing=ALL-UNNAMED", "--add-opens", "java.base/java.io=ALL-UNNAMED")
|
||||
}
|
||||
|
||||
codegenTest("codegen-target8-jvm8-test") {
|
||||
systemProperty("kotlin.test.default.jvm.target", "1.8")
|
||||
}
|
||||
|
||||
codegenTest("codegen-target8-jvm9-test") {
|
||||
systemProperty("kotlin.test.default.jvm.target", "1.8")
|
||||
jvmArgs = listOf("--add-opens", "java.desktop/javax.swing=ALL-UNNAMED", "--add-opens", "java.base/java.io=ALL-UNNAMED")
|
||||
}
|
||||
|
||||
codegenTest("codegen-target9-jvm9-test") {
|
||||
systemProperty("kotlin.test.default.jvm.target", "1.8")
|
||||
systemProperty("kotlin.test.substitute.bytecode.1.8.to.1.9", "true")
|
||||
jvmArgs = listOf("--add-opens", "java.desktop/javax.swing=ALL-UNNAMED", "--add-opens", "java.base/java.io=ALL-UNNAMED")
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
|
||||
apply { plugin("kotlin") }
|
||||
|
||||
jvmTarget = "1.6"
|
||||
|
||||
dependencies {
|
||||
compile(project(":core"))
|
||||
compile(project(":core::util.runtime"))
|
||||
compile(project(":compiler:util"))
|
||||
compile(project(":compiler:backend"))
|
||||
compile(project(":compiler:frontend"))
|
||||
compile(project(":compiler:frontend.java"))
|
||||
compile(project(":compiler:util"))
|
||||
compile(project(":compiler:cli-common"))
|
||||
compile(project(":compiler:cli"))
|
||||
compile(project(":kotlin-test:kotlin-test-jvm"))
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
"main" { projectDefault() }
|
||||
"test" {}
|
||||
}
|
||||
+19
-2
@@ -16,17 +16,34 @@
|
||||
|
||||
package org.jetbrains.kotlin.test.clientserver
|
||||
|
||||
import org.jetbrains.kotlin.codegen.getBoxMethodOrNull
|
||||
import org.jetbrains.kotlin.codegen.getGeneratedClass
|
||||
import java.io.File
|
||||
import java.io.ObjectInputStream
|
||||
import java.io.ObjectOutputStream
|
||||
import java.lang.reflect.Method
|
||||
import java.net.ServerSocket
|
||||
import java.net.Socket
|
||||
import java.net.URL
|
||||
import java.net.URLClassLoader
|
||||
import java.util.concurrent.Executors
|
||||
|
||||
fun getGeneratedClass(classLoader: ClassLoader, className: String): Class<*> {
|
||||
try {
|
||||
return classLoader.loadClass(className)
|
||||
}
|
||||
catch (e: ClassNotFoundException) {
|
||||
error("No class file was generated for: " + className)
|
||||
}
|
||||
}
|
||||
|
||||
fun getBoxMethodOrNull(aClass: Class<*>): Method? {
|
||||
try {
|
||||
return aClass.getMethod("box")
|
||||
}
|
||||
catch (e: NoSuchMethodException) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
//Use only JDK 1.6 compatible api
|
||||
object TestProcessServer {
|
||||
|
||||
-1
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.test.clientserver
|
||||
|
||||
import org.jetbrains.kotlin.utils.rethrow
|
||||
import java.io.File
|
||||
import java.io.ObjectInputStream
|
||||
import java.io.ObjectOutputStream
|
||||
@@ -34,6 +34,8 @@ import java.util.List;
|
||||
|
||||
import static org.jetbrains.kotlin.codegen.TestUtilsKt.*;
|
||||
import static org.jetbrains.kotlin.test.KotlinTestUtils.assertEqualsToFile;
|
||||
import static org.jetbrains.kotlin.test.clientserver.TestProcessServerKt.getBoxMethodOrNull;
|
||||
import static org.jetbrains.kotlin.test.clientserver.TestProcessServerKt.getGeneratedClass;
|
||||
|
||||
public abstract class AbstractBlackBoxCodegenTest extends CodegenTestCase {
|
||||
|
||||
|
||||
@@ -80,6 +80,8 @@ import static org.jetbrains.kotlin.cli.common.output.outputUtils.OutputUtilsKt.w
|
||||
import static org.jetbrains.kotlin.codegen.CodegenTestUtil.*;
|
||||
import static org.jetbrains.kotlin.codegen.TestUtilsKt.*;
|
||||
import static org.jetbrains.kotlin.test.KotlinTestUtils.getAnnotationsJar;
|
||||
import static org.jetbrains.kotlin.test.clientserver.TestProcessServerKt.getBoxMethodOrNull;
|
||||
import static org.jetbrains.kotlin.test.clientserver.TestProcessServerKt.getGeneratedClass;
|
||||
|
||||
public abstract class CodegenTestCase extends KtUsefulTestCase {
|
||||
private static final String DEFAULT_TEST_FILE_NAME = "a_test";
|
||||
|
||||
@@ -35,23 +35,6 @@ fun clearReflectionCache(classLoader: ClassLoader) {
|
||||
}
|
||||
|
||||
|
||||
fun getGeneratedClass(classLoader: ClassLoader, className: String): Class<*> {
|
||||
try {
|
||||
return classLoader.loadClass(className)
|
||||
}
|
||||
catch (e: ClassNotFoundException) {
|
||||
error("No class file was generated for: " + className)
|
||||
}
|
||||
}
|
||||
|
||||
fun getBoxMethodOrNull(aClass: Class<*>): Method? {
|
||||
try {
|
||||
return aClass.getMethod("box")
|
||||
}
|
||||
catch (e: NoSuchMethodException) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
fun ClassLoader?.extractUrls(): List<URL> {
|
||||
return (this as? URLClassLoader)?.let {
|
||||
|
||||
@@ -46,7 +46,7 @@ object CodegenJdkCommonTestSuite {
|
||||
fun setUp() {
|
||||
val boxInSeparateProcessPort = System.getProperty(CodegenTestCase.RUN_BOX_TEST_IN_SEPARATE_PROCESS_PORT)
|
||||
if (boxInSeparateProcessPort != null) {
|
||||
val classpath = "out/test/tests-common" +
|
||||
val classpath = (System.getenv("TEST_SERVER_CLASSES_DIRS") ?: "out/test/tests-common") +
|
||||
File.pathSeparatorChar +
|
||||
ForTestCompileRuntime.runtimeJarForTests() +
|
||||
File.pathSeparatorChar +
|
||||
|
||||
Reference in New Issue
Block a user