Move server process creation to JDK 6 suite

It's allow to avoid problem with wrong inherited output
 (gradle instead of test process)
This commit is contained in:
Mikhael Bogdanov
2019-05-01 20:54:45 +02:00
parent bfe148efd5
commit 6dbbf0bb72
2 changed files with 55 additions and 29 deletions
+3 -27
View File
@@ -42,36 +42,12 @@ fun Project.codegenTest(target: Int, jvm: Int,
codegenTest(target = 6, jvm = 6, jdk = "JDK_18") {
dependsOn(testJvm6ServerRuntime)
val port = project.findProperty("kotlin.compiler.codegen.tests.port")?.toString() ?: "5100"
var jdkProcess: Process? = null
doFirst {
logger.info("Configuring JDK 6 server...")
val jdkPath = project.findProperty("JDK_16") ?: error("JDK_16 is not optional to run this test")
val executable = "$jdkPath/bin/java"
val main = "org.jetbrains.kotlin.test.clientserver.TestProcessServer"
val classpath = testJvm6ServerRuntime.asPath
logger.debug("Server classpath: $classpath")
val builder = ProcessBuilder(executable, "-cp", classpath, main, port)
builder.directory(rootDir)
builder.inheritIO()
builder.redirectErrorStream(true)
logger.info("Starting JDK 6 server $executable")
jdkProcess = builder.start()
}
systemProperty("kotlin.test.default.jvm.target", "1.6")
systemProperty("kotlin.test.java.compilation.target", "1.6")
systemProperty("kotlin.test.box.in.separate.process.port", port)
doLast {
logger.info("Stopping JDK 6 server...")
jdkProcess?.destroy()
}
val port = project.findProperty("kotlin.compiler.codegen.tests.port") ?: "5100"
systemProperty("kotlin.test.box.in.separate.process.port", port)
systemProperty("kotlin.test.box.in.separate.process.server.classpath", testJvm6ServerRuntime.asPath)
}
codegenTest(target = 6, jvm = 9) {
@@ -6,10 +6,15 @@
package org.jetbrains.kotlin.codegen.jdk
import org.jetbrains.kotlin.codegen.*
import org.jetbrains.kotlin.test.SuiteRunnerForCustomJdk
import org.jetbrains.kotlin.codegen.CodegenTestCase.RUN_BOX_TEST_IN_SEPARATE_PROCESS_PORT
import org.jetbrains.kotlin.test.RunOnlyJdk6Test
import org.jetbrains.kotlin.test.SuiteRunnerForCustomJdk
import org.junit.AfterClass
import org.junit.BeforeClass
import org.junit.runner.RunWith
import org.junit.runners.Suite
import java.io.File
import kotlin.test.assertTrue
/*
* NB: ALL NECESSARY FLAGS ARE PASSED THROUGH Gradle
@@ -26,7 +31,52 @@ abstract class CustomJvmTargetOnJvmBaseTest
@RunOnlyJdk6Test
@RunWith(SuiteRunnerForCustomJdk::class)
class JvmTarget6OnJvm6 : CustomJvmTargetOnJvmBaseTest()
class JvmTarget6OnJvm6 : CustomJvmTargetOnJvmBaseTest() {
companion object {
private lateinit var jdkProcess: Process
@JvmStatic
@BeforeClass
fun setUp() {
println("Configuring JDK6 Test server...")
val jdkPath = System.getenv("JDK_16") ?: error("JDK_16 is not optional to run this test")
val executable = File(jdkPath, "bin/java").canonicalPath
val main = "org.jetbrains.kotlin.test.clientserver.TestProcessServer"
val classpath =
System.getProperty("kotlin.test.box.in.separate.process.server.classpath") ?: System.getProperty("java.class.path")
println("Server classpath: $classpath")
val port = System.getProperty(RUN_BOX_TEST_IN_SEPARATE_PROCESS_PORT)
?: error("$RUN_BOX_TEST_IN_SEPARATE_PROCESS_PORT is not specified")
val builder = ProcessBuilder(executable, "-cp", classpath, main, port)
builder.inheritIO()
println("Starting JDK 6 server $executable...")
jdkProcess = builder.start()
Thread.sleep(2000)
assertTrue(jdkProcess.isAlive, "Test server process hasn't started")
println("Test server started!")
Runtime.getRuntime().addShutdownHook(object : Thread() {
override fun run() {
tearDown()
}
})
}
@JvmStatic
@AfterClass
fun tearDown() {
println("Stopping JDK 6 server...")
if (::jdkProcess.isInitialized) {
jdkProcess.destroy()
}
}
}
}
@RunWith(SuiteRunnerForCustomJdk::class)
class JvmTarget8OnJvm8 : CustomJvmTargetOnJvmBaseTest()