Remove :compiler:tests-common-jvm6 project and JvmTarget6OnBaseJvm tests

This commit is contained in:
Abduqodiri Qurbonzoda
2022-07-12 11:49:28 +03:00
parent de775ad728
commit cf44753aed
17 changed files with 61 additions and 432 deletions
@@ -3,8 +3,6 @@ plugins {
id("jps-compatible")
}
val testJvm6ServerRuntime by configurations.creating
dependencies {
testApi(projectTests(":compiler"))
testApi(projectTests(":compiler:test-infrastructure"))
@@ -16,7 +14,6 @@ dependencies {
testImplementation(intellijCore())
testRuntimeOnly(project(":kotlin-reflect"))
testJvm6ServerRuntime(projectTests(":compiler:tests-common-jvm6"))
}
sourceSets {
@@ -50,44 +47,16 @@ fun Project.codegenTest(
group = "verification"
}
// Should the tests with target = 6 be removed ?
codegenTest(
target = 6,
jdk = JdkMajorVersion.JDK_1_8,
jvm = JdkMajorVersion.JDK_1_6.majorVersion.toString()
) {
dependsOn(testJvm6ServerRuntime)
doFirst {
systemProperty("kotlin.test.default.jvm.target", "1.6")
systemProperty("kotlin.test.java.compilation.target", "1.6")
systemProperty(
"JDK_16",
project.getToolchainLauncherFor(JdkMajorVersion.JDK_1_6).get().metadata.installationPath.asFile.absolutePath
)
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)
}
}
//JDK 8
codegenTest(target = 6, jdk = JdkMajorVersion.JDK_1_8)
// This is default one and is executed in default build configuration
codegenTest(target = 8, jdk = JdkMajorVersion.JDK_1_8)
//JDK 11
codegenTest(target = 6, jdk = JdkMajorVersion.JDK_11)
codegenTest(target = 8, jdk = JdkMajorVersion.JDK_11)
codegenTest(target = 11, jdk = JdkMajorVersion.JDK_11)
//JDK 17
codegenTest(target = 6, jdk = JdkMajorVersion.JDK_17)
codegenTest(target = 8, jdk = JdkMajorVersion.JDK_17)
codegenTest(target = 17, jdk = JdkMajorVersion.JDK_17) {
@@ -98,7 +67,6 @@ codegenTest(target = 17, jdk = JdkMajorVersion.JDK_17) {
val mostRecentJdk = JdkMajorVersion.values().last()
//LAST JDK from JdkMajorVersion available on machine
codegenTest(target = 6, jvm = "Last", jdk = mostRecentJdk)
codegenTest(target = 8, jvm = "Last", jdk = mostRecentJdk)
codegenTest(
@@ -8,8 +8,6 @@
package org.jetbrains.kotlin.codegen.jdk
import org.jetbrains.kotlin.test.runners.codegen.*
import org.junit.jupiter.api.parallel.Execution
import org.junit.jupiter.api.parallel.ExecutionMode
import org.junit.platform.runner.JUnitPlatform
import org.junit.platform.suite.api.ExcludeTags
import org.junit.platform.suite.api.IncludeClassNamePatterns
@@ -35,23 +33,11 @@ import org.junit.runner.RunWith
@UseTechnicalNames
abstract class CustomJvmTargetOnJvmBaseTest
// JDK 6
@RunOnlyJdk6Test
@Execution(ExecutionMode.SAME_THREAD)
@RunWith(JUnitPlatformRunnerForJdk6::class)
class JvmTarget6OnJvm6 : CustomJvmTargetOnJvmBaseTest()
// JDK 8
@RunWith(JUnitPlatform::class)
class JvmTarget6OnJvm8 : CustomJvmTargetOnJvmBaseTest()
@RunWith(JUnitPlatform::class)
class JvmTarget8OnJvm8 : CustomJvmTargetOnJvmBaseTest()
// JDK 11
@RunWith(JUnitPlatform::class)
class JvmTarget6OnJvm11 : CustomJvmTargetOnJvmBaseTest()
@RunWith(JUnitPlatform::class)
class JvmTarget8OnJvm11 : CustomJvmTargetOnJvmBaseTest()
@@ -59,18 +45,12 @@ class JvmTarget8OnJvm11 : CustomJvmTargetOnJvmBaseTest()
class JvmTarget11OnJvm11 : CustomJvmTargetOnJvmBaseTest()
// JDK 15
@RunWith(JUnitPlatform::class)
class JvmTarget6OnJvm15 : CustomJvmTargetOnJvmBaseTest()
@RunWith(JUnitPlatform::class)
class JvmTarget8OnJvm15 : CustomJvmTargetOnJvmBaseTest()
@RunWith(JUnitPlatform::class)
class JvmTarget15OnJvm15 : CustomJvmTargetOnJvmBaseTest()
@RunWith(JUnitPlatform::class)
class JvmTarget6OnJvm17 : CustomJvmTargetOnJvmBaseTest()
@RunWith(JUnitPlatform::class)
class JvmTarget8OnJvm17 : CustomJvmTargetOnJvmBaseTest()
@@ -79,9 +59,6 @@ class JvmTarget17OnJvm17 : CustomJvmTargetOnJvmBaseTest()
// LAST JDK from JdkMajorVersion available on machine
@RunWith(JUnitPlatform::class)
class JvmTarget6OnJvmLast : CustomJvmTargetOnJvmBaseTest()
@RunWith(JUnitPlatform::class)
class JvmTarget8OnJvmLast : CustomJvmTargetOnJvmBaseTest()
@@ -1,56 +0,0 @@
/*
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@file:Suppress("DEPRECATION")
package org.jetbrains.kotlin.codegen.jdk
import org.jetbrains.kotlin.test.InTextDirectivesUtils
import org.jetbrains.kotlin.test.TestMetadata
import org.junit.platform.runner.JUnitPlatform
import org.junit.runner.Description
import org.junit.runner.manipulation.Filter
import org.junit.runner.notification.RunNotifier
import java.io.File
annotation class RunOnlyJdk6Test
class JUnitPlatformRunnerForJdk6(testClass: Class<*>) : JUnitPlatform(testClass) {
init {
if (testClass.getAnnotation(RunOnlyJdk6Test::class.java) != null) {
this.filter(object : Filter() {
override fun shouldRun(description: Description): Boolean {
if (description.isTest) {
@Suppress("NAME_SHADOWING")
val testClass = description.testClass ?: return true
val methodName = description.methodName ?: return true
val testClassAnnotation = testClass.getAnnotation(TestMetadata::class.java) ?: return true
val method = testClass.getMethod(methodName)
val methodAnnotation = method.getAnnotation(TestMetadata::class.java) ?: return true
val path = "${testClassAnnotation.value}/${methodAnnotation.value}"
val fileText = File(path).readText()
return !InTextDirectivesUtils.isDirectiveDefined(fileText, "// JVM_TARGET:") &&
!InTextDirectivesUtils.isDirectiveDefined(fileText, "// SKIP_JDK6")
}
return true
}
override fun describe(): String {
return "skipped on JDK 6"
}
})
}
}
override fun run(notifier: RunNotifier?) {
SeparateJavaProcessHelper.setUp()
try {
super.run(notifier)
} finally {
SeparateJavaProcessHelper.tearDown()
}
}
}
@@ -1,73 +0,0 @@
/*
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.codegen.jdk
import org.jetbrains.kotlin.codegen.CodegenTestCase
import java.io.File
import java.util.concurrent.locks.ReentrantLock
import kotlin.concurrent.withLock
import kotlin.test.assertTrue
object SeparateJavaProcessHelper {
private lateinit var jdkProcess: Process
private val lock = ReentrantLock()
private var counter = 0
fun setUp() {
lock.withLock {
if (counter == 0) {
initJdkProcess()
}
counter += 1
}
}
fun tearDown() {
lock.withLock {
counter -= 1
if (counter == 0) {
destroyJdkProcess()
}
}
}
private fun initJdkProcess() {
println("Configuring JDK6 Test server...")
val jdkPath = System.getProperty("JDK_16") ?: error("JDK_16 is not optional to run this test")
val executable = File(jdkPath, "bin/java").canonicalPath
assert(File(executable).exists()) { "Not a JDK path: $jdkPath"}
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 = CodegenTestCase.BOX_IN_SEPARATE_PROCESS_PORT ?: error("kotlin.test.box.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() {
destroyJdkProcess()
}
})
}
private fun destroyJdkProcess() {
println("Stopping JDK 6 server...")
if (::jdkProcess.isInitialized) {
jdkProcess.destroy()
}
}
}