diff --git a/compiler/test-infrastructure-utils/tests/org/jetbrains/kotlin/test/KtAssert.kt b/compiler/test-infrastructure-utils/tests/org/jetbrains/kotlin/test/KtAssert.kt index 40e2bca4c32..561a59a67bd 100644 --- a/compiler/test-infrastructure-utils/tests/org/jetbrains/kotlin/test/KtAssert.kt +++ b/compiler/test-infrastructure-utils/tests/org/jetbrains/kotlin/test/KtAssert.kt @@ -14,7 +14,7 @@ import kotlin.contracts.contract */ object KtAssert { @JvmStatic - fun fail(message: String) { + fun fail(message: String): Nothing { throw AssertionError(message) } diff --git a/compiler/tests-common-jvm6/build.gradle.kts b/compiler/tests-common-jvm6/build.gradle.kts deleted file mode 100644 index 9a0ea5db9e0..00000000000 --- a/compiler/tests-common-jvm6/build.gradle.kts +++ /dev/null @@ -1,18 +0,0 @@ -plugins { - kotlin("jvm") - id("jps-compatible") -} - -project.updateJvmTarget("1.6") // Should this project be removed altogether ? - -dependencies { - api(kotlinStdlib()) - testApi(project(":kotlin-test:kotlin-test-jvm")) -} - -sourceSets { - "main" { } - "test" { projectDefault() } -} - -testsJar {} diff --git a/compiler/tests-common-jvm6/tests/org/jetbrains/kotlin/test/clientserver/MessageHeader.kt b/compiler/tests-common-jvm6/tests/org/jetbrains/kotlin/test/clientserver/MessageHeader.kt deleted file mode 100644 index c2bfc48c0e4..00000000000 --- a/compiler/tests-common-jvm6/tests/org/jetbrains/kotlin/test/clientserver/MessageHeader.kt +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2010-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.test.clientserver - -enum class MessageHeader { - NEW_TEST, - CLASS_PATH, - RESULT, - ERROR -} \ No newline at end of file diff --git a/compiler/tests-common-jvm6/tests/org/jetbrains/kotlin/test/clientserver/TestProcessServer.kt b/compiler/tests-common-jvm6/tests/org/jetbrains/kotlin/test/clientserver/TestProcessServer.kt deleted file mode 100644 index 65e30610c21..00000000000 --- a/compiler/tests-common-jvm6/tests/org/jetbrains/kotlin/test/clientserver/TestProcessServer.kt +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright 2010-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.test.clientserver - -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 -import java.util.concurrent.ScheduledFuture -import java.util.concurrent.TimeUnit - -private fun ClassLoader.loadClassOrNull(name: String): Class<*>? = - try { - loadClass(name) - } catch (e: ClassNotFoundException) { - null - } - -private fun Class<*>.getMethodOrNull(name: String, vararg parameterTypes: Class<*>): Method? = - try { - getMethod(name, *parameterTypes) - } catch (e: NoSuchMethodException) { - null - } - -fun getGeneratedClass(classLoader: ClassLoader, className: String): Class<*> = - classLoader.loadClassOrNull(className) ?: error("No class file was generated for: $className") - -fun getBoxMethodOrNull(aClass: Class<*>): Method? = - aClass.getMethodOrNull("box") - ?: aClass.classLoader.loadClassOrNull("kotlin.coroutines.Continuation")?.let { aClass.getMethodOrNull("box", it) } - ?: aClass.classLoader.loadClassOrNull("kotlin.coroutines.experimental.Continuation")?.let { aClass.getMethodOrNull("box", it) } - -fun runBoxMethod(method: Method): String? { - if (method.parameterTypes.isEmpty()) { - return method.invoke(null) as? String - } - val emptyContinuationClass = method.declaringClass.classLoader.loadClass("helpers.ResultContinuation") - val emptyContinuation = emptyContinuationClass.declaredConstructors.single().newInstance() - val result = method.invoke(null, emptyContinuation) - val resultAfterSuspend = emptyContinuationClass.getField("result").get(emptyContinuation) - return (resultAfterSuspend ?: result) as? String -} - -//Use only JDK 1.6 compatible api -object TestProcessServer { - - const val DEBUG_TEST = "--debugTest" - - private val executor = Executors.newFixedThreadPool(1)!! - - @Volatile - private var isProcessingTask = true - - @Volatile - private var lastTime = System.currentTimeMillis() - - private val scheduler = Executors.newScheduledThreadPool(1) - - private lateinit var handler: ScheduledFuture<*> - - private lateinit var serverSocket: ServerSocket - - private var suppressOutput = false - private var allocatePort = false - - @JvmStatic - fun main(args: Array) { - if (args[0] == DEBUG_TEST) { - suppressOutput = true - allocatePort = true - } - - val portNumber = if (allocatePort) 0 else args[0].toInt() - println("Starting server on port $portNumber...") - val serverSocket = ServerSocket(portNumber) - println("...server started on port ${serverSocket.localPort}") - scheduleShutdownProcess() - - try { - while (true) { - lastTime = System.currentTimeMillis() - isProcessingTask = false - val clientSocket = serverSocket.accept() - isProcessingTask = true - println("Socket established...") - executor.execute(ServerTest(clientSocket, suppressOutput)) - } - } - finally { - handler.cancel(false) - scheduler.shutdown() - serverSocket.close() - println("Server stopped!") - } - } - - private fun scheduleShutdownProcess() { - handler = scheduler.scheduleAtFixedRate({ - if (!isProcessingTask && (System.currentTimeMillis() - lastTime) >= 60 * 1000 /*60 sec*/) { - println("Stopping server...") - serverSocket.close() - } - }, 60, 60, TimeUnit.SECONDS) - } - - private fun printlnTest(text: String) { - if (!suppressOutput) { - println(text) - } - } -} - -private class ServerTest(val clientSocket: Socket, val suppressOutput: Boolean) : Runnable { - private lateinit var className: String - private lateinit var testMethod: String - - override fun run() { - val input = ObjectInputStream(clientSocket.getInputStream()) - val output = if (suppressOutput) null else ObjectOutputStream(clientSocket.getOutputStream()) - try { - var message = input.readObject() as MessageHeader - assert(message == MessageHeader.NEW_TEST, { "New test marker missed, but $message received" }) - className = input.readObject() as String - testMethod = input.readObject() as String - println("Preparing to execute test $className") - - message = input.readObject() as MessageHeader - assert(message == MessageHeader.CLASS_PATH, { "Class path marker missed, but $message received" }) - @Suppress("UNCHECKED_CAST") - val classPath = input.readObject() as Array - - val result = executeTest(URLClassLoader(classPath, JDK_EXT_JARS_CLASS_LOADER)) - output?.writeObject(MessageHeader.RESULT) - output?.writeObject(result) - } catch (e: Throwable) { - output?.writeObject(MessageHeader.ERROR) - output?.writeObject(e) - } finally { - output?.close() - input.close() - clientSocket.close() - } - } - - fun executeTest(classLoader: ClassLoader): String { - val clazz = getGeneratedClass(classLoader, className) - return runBoxMethod(getBoxMethodOrNull(clazz)!!) as String - } - - companion object { - //Required for org.jetbrains.kotlin.codegen.BlackBoxCodegenTestGenerated.FullJdk#testClasspath - val JDK_EXT_JARS_CLASS_LOADER: ClassLoader - init { - val javaHome = System.getProperty("java.home") - val extFolder = File(javaHome + "/lib/ext/") - println(extFolder.canonicalPath) - val listFiles = extFolder.listFiles() - val additionalJars = listFiles?.filter { it.name.endsWith(".jar") }?.map { it.toURI().toURL() } ?: emptyList() - JDK_EXT_JARS_CLASS_LOADER = URLClassLoader(additionalJars.toTypedArray(), null) - } - } -} \ No newline at end of file diff --git a/compiler/tests-common-new/build.gradle.kts b/compiler/tests-common-new/build.gradle.kts index 6416376b175..0bb42ff0bd6 100644 --- a/compiler/tests-common-new/build.gradle.kts +++ b/compiler/tests-common-new/build.gradle.kts @@ -23,7 +23,6 @@ dependencies { testApi(projectTests(":compiler:test-infrastructure")) testApi(projectTests(":compiler:test-infrastructure-utils")) testApi(projectTests(":compiler:tests-compiler-utils")) - testApi(projectTests(":compiler:tests-common-jvm6")) /* * Actually those dependencies are needed only at runtime, but they diff --git a/compiler/tests-common/build.gradle.kts b/compiler/tests-common/build.gradle.kts index c0371105ca5..d1a49db0347 100644 --- a/compiler/tests-common/build.gradle.kts +++ b/compiler/tests-common/build.gradle.kts @@ -52,7 +52,6 @@ dependencies { testApi(projectTests(":generators:test-generator")) testApi(projectTests(":compiler:tests-compiler-utils")) testApi(project(":kotlin-test:kotlin-test-jvm")) - testApi(projectTests(":compiler:tests-common-jvm6")) testApi(project(":kotlin-scripting-compiler-impl")) testApi(projectTests(":compiler:test-infrastructure-utils")) testApi(commonDependency("junit:junit")) diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractBlackBoxCodegenTest.java b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractBlackBoxCodegenTest.java index f51577bae8a..418318cd720 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractBlackBoxCodegenTest.java +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractBlackBoxCodegenTest.java @@ -22,8 +22,8 @@ import java.lang.reflect.Method; import java.util.List; 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; +import static org.jetbrains.kotlin.codegen.CodegenTestUtilsKt.getBoxMethodOrNull; +import static org.jetbrains.kotlin.codegen.CodegenTestUtilsKt.getGeneratedClass; @ObsoleteTestInfrastructure(replacer = "org.jetbrains.kotlin.test.runners.codegen.AbstractBlackBoxCodegenTest") public abstract class AbstractBlackBoxCodegenTest extends CodegenTestCase { diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/CodegenTestCase.java b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/CodegenTestCase.java index d5acc1409b3..8b28dca0fc9 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/CodegenTestCase.java +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/CodegenTestCase.java @@ -19,12 +19,10 @@ import org.jetbrains.kotlin.TestsCompilerError; import org.jetbrains.kotlin.TestsCompiletimeError; import org.jetbrains.kotlin.backend.common.output.SimpleOutputFileCollection; import org.jetbrains.kotlin.checkers.utils.CheckerTestUtil; -import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys; import org.jetbrains.kotlin.cli.common.output.OutputUtilsKt; import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles; import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment; import org.jetbrains.kotlin.cli.jvm.compiler.NoScopeRecordCliBindingTrace; -import org.jetbrains.kotlin.cli.jvm.config.JvmClasspathRoot; import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime; import org.jetbrains.kotlin.codegen.state.GenerationState; import org.jetbrains.kotlin.config.CompilerConfiguration; @@ -54,7 +52,7 @@ import java.util.stream.Collectors; import static org.jetbrains.kotlin.cli.common.output.OutputUtilsKt.writeAllTo; import static org.jetbrains.kotlin.codegen.CodegenTestUtil.*; import static org.jetbrains.kotlin.codegen.TestUtilsKt.extractUrls; -import static org.jetbrains.kotlin.test.clientserver.TestProcessServerKt.*; +import static org.jetbrains.kotlin.codegen.CodegenTestUtilsKt.*; import static org.jetbrains.kotlin.test.util.KtTestUtil.getAnnotationsJar; public abstract class CodegenTestCase extends KotlinBaseTest { diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/CodegenTestUtils.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/CodegenTestUtils.kt new file mode 100644 index 00000000000..41dfdc307d0 --- /dev/null +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/CodegenTestUtils.kt @@ -0,0 +1,41 @@ +/* + * Copyright 2010-2022 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 + +import java.lang.reflect.Method + +private fun ClassLoader.loadClassOrNull(name: String): Class<*>? = + try { + loadClass(name) + } catch (e: ClassNotFoundException) { + null + } + +private fun Class<*>.getMethodOrNull(name: String, vararg parameterTypes: Class<*>): Method? = + try { + getMethod(name, *parameterTypes) + } catch (e: NoSuchMethodException) { + null + } + +fun getGeneratedClass(classLoader: ClassLoader, className: String): Class<*> = + classLoader.loadClassOrNull(className) ?: error("No class file was generated for: $className") + +fun getBoxMethodOrNull(aClass: Class<*>): Method? = + aClass.getMethodOrNull("box") + ?: aClass.classLoader.loadClassOrNull("kotlin.coroutines.Continuation")?.let { aClass.getMethodOrNull("box", it) } + ?: aClass.classLoader.loadClassOrNull("kotlin.coroutines.experimental.Continuation")?.let { aClass.getMethodOrNull("box", it) } + +fun runBoxMethod(method: Method): String? { + if (method.parameterTypes.isEmpty()) { + return method.invoke(null) as? String + } + val emptyContinuationClass = method.declaringClass.classLoader.loadClass("helpers.ResultContinuation") + val emptyContinuation = emptyContinuationClass.declaredConstructors.single().newInstance() + val result = method.invoke(null, emptyContinuation) + val resultAfterSuspend = emptyContinuationClass.getField("result").get(emptyContinuation) + return (resultAfterSuspend ?: result) as? String +} diff --git a/compiler/tests-compiler-utils/tests/org/jetbrains/kotlin/test/clientserver/MessageHeader.kt b/compiler/tests-compiler-utils/tests/org/jetbrains/kotlin/test/clientserver/MessageHeader.kt new file mode 100644 index 00000000000..27dce7b52ed --- /dev/null +++ b/compiler/tests-compiler-utils/tests/org/jetbrains/kotlin/test/clientserver/MessageHeader.kt @@ -0,0 +1,13 @@ +/* + * Copyright 2010-2022 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.test.clientserver + +enum class MessageHeader { + NEW_TEST, + CLASS_PATH, + RESULT, + ERROR +} \ No newline at end of file diff --git a/compiler/tests-common-jvm6/tests/org/jetbrains/kotlin/test/clientserver/TestProxy.kt b/compiler/tests-compiler-utils/tests/org/jetbrains/kotlin/test/clientserver/TestProxy.kt similarity index 78% rename from compiler/tests-common-jvm6/tests/org/jetbrains/kotlin/test/clientserver/TestProxy.kt rename to compiler/tests-compiler-utils/tests/org/jetbrains/kotlin/test/clientserver/TestProxy.kt index ec3cf70f4a2..d4f5cf43d59 100644 --- a/compiler/tests-common-jvm6/tests/org/jetbrains/kotlin/test/clientserver/TestProxy.kt +++ b/compiler/tests-compiler-utils/tests/org/jetbrains/kotlin/test/clientserver/TestProxy.kt @@ -1,17 +1,6 @@ /* - * Copyright 2010-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2010-2022 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.test.clientserver @@ -21,7 +10,7 @@ import java.io.ObjectInputStream import java.io.ObjectOutputStream import java.net.Socket import java.net.URL -import kotlin.test.fail +import org.jetbrains.kotlin.test.KtAssert.fail class TestProxy(val serverPort: Int, val testClass: String, val classPath: List) { diff --git a/compiler/tests-different-jdk/build.gradle.kts b/compiler/tests-different-jdk/build.gradle.kts index 9a4ddb9a5e5..801200fdf7e 100644 --- a/compiler/tests-different-jdk/build.gradle.kts +++ b/compiler/tests-different-jdk/build.gradle.kts @@ -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( diff --git a/compiler/tests-different-jdk/tests/org/jetbrains/kotlin/codegen/jdk/CustomJvmTargetOnJvmBaseTest.kt b/compiler/tests-different-jdk/tests/org/jetbrains/kotlin/codegen/jdk/CustomJvmTargetOnJvmBaseTest.kt index e39290f7304..db47dc89615 100644 --- a/compiler/tests-different-jdk/tests/org/jetbrains/kotlin/codegen/jdk/CustomJvmTargetOnJvmBaseTest.kt +++ b/compiler/tests-different-jdk/tests/org/jetbrains/kotlin/codegen/jdk/CustomJvmTargetOnJvmBaseTest.kt @@ -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() diff --git a/compiler/tests-different-jdk/tests/org/jetbrains/kotlin/codegen/jdk/JUnitPlatformRunnerForJdk6.kt b/compiler/tests-different-jdk/tests/org/jetbrains/kotlin/codegen/jdk/JUnitPlatformRunnerForJdk6.kt deleted file mode 100644 index a01daf7cfee..00000000000 --- a/compiler/tests-different-jdk/tests/org/jetbrains/kotlin/codegen/jdk/JUnitPlatformRunnerForJdk6.kt +++ /dev/null @@ -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() - } - } -} diff --git a/compiler/tests-different-jdk/tests/org/jetbrains/kotlin/codegen/jdk/SeparateJavaProcessHelper.kt b/compiler/tests-different-jdk/tests/org/jetbrains/kotlin/codegen/jdk/SeparateJavaProcessHelper.kt deleted file mode 100644 index 75c9d7efb3c..00000000000 --- a/compiler/tests-different-jdk/tests/org/jetbrains/kotlin/codegen/jdk/SeparateJavaProcessHelper.kt +++ /dev/null @@ -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() - } - } -} diff --git a/prepare/kotlin-compiler-internal-test-framework/build.gradle.kts b/prepare/kotlin-compiler-internal-test-framework/build.gradle.kts index 5ccd2aa2d97..dbd6f7fff3a 100644 --- a/prepare/kotlin-compiler-internal-test-framework/build.gradle.kts +++ b/prepare/kotlin-compiler-internal-test-framework/build.gradle.kts @@ -3,7 +3,6 @@ plugins { } val testModules = listOf( - ":compiler:tests-common-jvm6", ":compiler:test-infrastructure", ":compiler:test-infrastructure-utils", ":compiler:tests-compiler-utils", diff --git a/settings.gradle b/settings.gradle index 252412d3574..6ff6f8c89a6 100644 --- a/settings.gradle +++ b/settings.gradle @@ -153,7 +153,6 @@ include ":benchmarks", ":compiler:tests-common", ":compiler:tests-mutes", ":compiler:tests-mutes:tc-integration", - ":compiler:tests-common-jvm6", ":compiler:tests-against-klib", ":compiler:tests-for-compiler-generator", ":js:js.ast",