[Test] Merge box against java tests into codegen black box tests

This commit is contained in:
Dmitriy Novozhilov
2021-01-27 16:19:22 +03:00
parent 6f3713af5f
commit 99cb85ab00
173 changed files with 117615 additions and 117302 deletions
@@ -1,57 +0,0 @@
/*
* Copyright 2010-2016 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.codegen
import org.jetbrains.kotlin.ObsoleteTestInfrastructure
import org.jetbrains.kotlin.cli.jvm.config.addJvmClasspathRoot
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.config.JvmTarget
import org.jetbrains.kotlin.test.util.JUnit4Assertions
import java.io.File
@OptIn(ObsoleteTestInfrastructure::class)
abstract class AbstractBlackBoxAgainstJavaCodegenTest : AbstractBlackBoxCodegenTest() {
override fun doMultiFileTest(wholeFile: File, files: List<TestFile>) {
javaClassesOutputDirectory = writeJavaFiles(files)!!.let { directory ->
val jvmTargets = files.mapNotNullTo(mutableSetOf()) { it.directives["JVM_TARGET"]?.let((JvmTarget)::fromString) }
val enablePreview = files.any { it.directives.contains("ENABLE_JVM_PREVIEW") }
check(jvmTargets.size <= 1) { "Having different JVM_TARGETs for different files is not supported in this test." }
CodegenTestUtil.compileJava(
CodegenTestUtil.findJavaSourcesInDirectory(directory),
emptyList(),
extractJavacOptions(
files,
jvmTargets.firstOrNull(),
enablePreview,
),
JUnit4Assertions
)
}
super.doMultiFileTest(wholeFile, files.map { file ->
// This is a hack which allows to avoid compiling Java sources for the second time (which would be incorrect in this test),
// while also retaining content of all Java sources so that we could find and use test directives in Java sources
// in CodegenTestCase.compile.
if (file.name.endsWith(".java")) TestFile("${file.name}.disabled", file.content) else file
})
}
override fun updateConfiguration(configuration: CompilerConfiguration) {
super.updateConfiguration(configuration)
configuration.addJvmClasspathRoot(javaClassesOutputDirectory)
}
}
@@ -1,18 +0,0 @@
/*
* Copyright 2010-2020 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.ir
import org.jetbrains.kotlin.config.CommonConfigurationKeys
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.config.JVMConfigurationKeys
abstract class AbstractFirBlackBoxAgainstJavaCodegenTest : AbstractIrBlackBoxAgainstJavaCodegenTest() {
override fun updateConfiguration(configuration: CompilerConfiguration) {
super.updateConfiguration(configuration)
configuration.put(CommonConfigurationKeys.USE_FIR, true)
configuration.put(JVMConfigurationKeys.IR, true)
}
}
@@ -1,13 +0,0 @@
/*
* Copyright 2010-2018 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.ir
import org.jetbrains.kotlin.codegen.AbstractBlackBoxAgainstJavaCodegenTest
import org.jetbrains.kotlin.test.TargetBackend
abstract class AbstractIrBlackBoxAgainstJavaCodegenTest : AbstractBlackBoxAgainstJavaCodegenTest() {
override val backend = TargetBackend.JVM_IR
}