diff --git a/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/AbstractIrKotlinKapt3Test.kt b/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/AbstractIrKotlinKapt3Test.kt index c9a98161126..cf0adfe1cc5 100644 --- a/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/AbstractIrKotlinKapt3Test.kt +++ b/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/AbstractIrKotlinKapt3Test.kt @@ -7,7 +7,7 @@ package org.jetbrains.kotlin.kapt3.test import org.jetbrains.kotlin.test.TargetBackend -abstract class AbstractIrClassFileToSourceStubConverterTest : AbstractClassFileToSourceStubConverterTest() { +open class AbstractIrClassFileToSourceStubConverterTest : AbstractClassFileToSourceStubConverterTest() { override val backend = TargetBackend.JVM_IR } diff --git a/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/AbstractKotlinKapt3Test.kt b/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/AbstractKotlinKapt3Test.kt index e655c282bf8..4f376057f72 100644 --- a/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/AbstractKotlinKapt3Test.kt +++ b/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/AbstractKotlinKapt3Test.kt @@ -56,6 +56,7 @@ import org.jetbrains.kotlin.resolve.jvm.extensions.AnalysisHandlerExtension import org.jetbrains.kotlin.resolve.jvm.extensions.PartialAnalysisHandlerExtension import org.jetbrains.kotlin.test.ConfigurationKind import org.jetbrains.kotlin.test.KotlinTestUtils +import org.jetbrains.kotlin.test.TargetBackend import org.jetbrains.kotlin.test.TestJdkKind import org.jetbrains.kotlin.test.util.trimTrailingWhitespacesAndAddNewlineAtEOF import org.jetbrains.kotlin.utils.PathUtil @@ -246,11 +247,17 @@ open class AbstractClassFileToSourceStubConverterTest : AbstractKotlinKapt3Test( @JvmStatic fun main(args: Array) { - if (args.isEmpty()) error("1 argument expected, 0 passed") - val test = AbstractClassFileToSourceStubConverterTest() + if (args.size != 2) error("2 argument expected, ${args.size} passed") + + val test = when (args[0]) { + TargetBackend.JVM.name -> AbstractClassFileToSourceStubConverterTest() + TargetBackend.JVM_IR.name -> AbstractIrClassFileToSourceStubConverterTest() + else -> throw UnsupportedOperationException(args[0]) + } + try { test.setUp() - test.doTest(args[0]) + test.doTest(args[1]) } finally { test.tearDown() } @@ -273,7 +280,7 @@ open class AbstractClassFileToSourceStubConverterTest : AbstractKotlinKapt3Test( addOrRemoveFlag(KaptFlag.KEEP_KDOC_COMMENTS_IN_STUBS, testFile) super.doTest(filePath) - doTestWithJdk11(AbstractClassFileToSourceStubConverterTest::class.java, filePath) + doTestWithJdk11(AbstractClassFileToSourceStubConverterTest::class.java, backend.name, filePath) } override fun check(kaptContext: KaptContextForStubGeneration, javaFiles: List, txtFile: File, wholeFile: File) { diff --git a/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/java9TestUtils.kt b/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/java9TestUtils.kt index ebdf8463cbf..8db1511897a 100644 --- a/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/java9TestUtils.kt +++ b/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/java9TestUtils.kt @@ -26,12 +26,12 @@ import java.net.URLClassLoader import java.util.concurrent.TimeUnit interface CustomJdkTestLauncher { - fun doTestWithJdk11(mainClass: Class<*>, arg: String) { + fun doTestWithJdk11(mainClass: Class<*>, vararg args: String) { if (isJava9OrLater()) return - KtTestUtil.getJdk11Home().let { doTestCustomJdk(mainClass, arg, it) } + doTestCustomJdk(mainClass, KtTestUtil.getJdk11Home(), *args) } - private fun doTestCustomJdk(mainClass: Class<*>, arg: String, javaHome: File) { + private fun doTestCustomJdk(mainClass: Class<*>, javaHome: File, vararg args: String) { //TODO unmute after investigation (tests are failing on TeamCity) if (SystemInfoRt.isWindows) return @@ -52,16 +52,21 @@ interface CustomJdkTestLauncher { "-classpath", classpath.joinToString(File.pathSeparator), mainClass.name, - arg + *args ) - println("Process arguments: [${command.joinToString()}]") - - val process = ProcessBuilder(*command).inheritIO().start() - + val process = ProcessBuilder(*command).start() + val stdout = process.inputStream.bufferedReader().use { it.readText() } + val stderr = process.errorStream.bufferedReader().use { it.readText() } process.waitFor(3, TimeUnit.MINUTES) - if (process.exitValue() != 0) { - throw AssertionError("Java $javaHome test process exited with exit code ${process.exitValue()} \n") + + val exitCode = process.exitValue() + if (exitCode != 0) { + throw AssertionError( + "Java $javaHome test process exited with exit code $exitCode\n\n" + + "--- STDOUT ---\n$stdout\n\n" + + "--- STDERR ---\n$stderr" + ) } } @@ -70,5 +75,4 @@ interface CustomJdkTestLauncher { is ClassLoader -> collectClasspath(classLoader.parent) else -> emptyList() } - }