IrCompileKotlinAgainstInlineKotlin tests

This commit is contained in:
Georgy Bronnikov
2019-09-03 17:48:49 +03:00
parent 0807987ef7
commit 7ede26e8f4
228 changed files with 4542 additions and 250 deletions
@@ -21,7 +21,7 @@ import java.io.File
abstract class AbstractCompileKotlinAgainstInlineKotlinTest : AbstractCompileKotlinAgainstKotlinTest() {
override fun doMultiFileTest(wholeFile: File, files: List<TestFile>) {
val isIgnored = InTextDirectivesUtils.isIgnoredTarget(backend, wholeFile)
val isIgnored = InTextDirectivesUtils.isIgnoredTarget(backend, wholeFile, ignoreBackendDirectivePrefix)
val (factory1, factory2) = doTwoFileTest(
files.filter { it.name.endsWith(".kt") },
!isIgnored
@@ -38,4 +38,6 @@ abstract class AbstractCompileKotlinAgainstInlineKotlinTest : AbstractCompileKot
throw e
}
}
override fun getIgnoreBackendDirectivePrefix(): String = "// IGNORE_BACKEND_MULTI_MODULE: "
}
@@ -890,9 +890,13 @@ public abstract class CodegenTestCase extends KtUsefulTestCase {
}
protected void printReport(File wholeFile) {
boolean isIgnored = InTextDirectivesUtils.isIgnoredTarget(getBackend(), wholeFile);
boolean isIgnored = InTextDirectivesUtils.isIgnoredTarget(getBackend(), wholeFile, getIgnoreBackendDirectivePrefix());
if (!isIgnored) {
System.out.println(generateToText());
}
}
protected String getIgnoreBackendDirectivePrefix() {
return InTextDirectivesUtils.IGNORE_BACKEND_DIRECTIVE_PREFIX;
}
}
@@ -0,0 +1,16 @@
/*
* Copyright 2010-2019 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.AbstractCompileKotlinAgainstInlineKotlinTest
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.config.JVMConfigurationKeys
import org.jetbrains.kotlin.test.TargetBackend
abstract class AbstractIrCompileKotlinAgainstInlineKotlinTest : AbstractCompileKotlinAgainstInlineKotlinTest() {
override fun updateConfiguration(configuration: CompilerConfiguration) = configuration.put(JVMConfigurationKeys.IR, true)
override fun getBackend() = TargetBackend.JVM_IR
}
@@ -229,13 +229,17 @@ public final class InTextDirectivesUtils {
return backends.isEmpty() || backends.contains(targetBackend.name()) || backends.contains(targetBackend.getCompatibleWith().name());
}
public static boolean isIgnoredTarget(TargetBackend targetBackend, File file) {
public static boolean isIgnoredTarget(TargetBackend targetBackend, File file, String ignoreBackendDirectivePrefix) {
if (targetBackend == TargetBackend.ANY) return false;
List<String> ignoredBackends = findListWithPrefixes(textWithDirectives(file), IGNORE_BACKEND_DIRECTIVE_PREFIX);
List<String> ignoredBackends = findListWithPrefixes(textWithDirectives(file), ignoreBackendDirectivePrefix);
return ignoredBackends.contains(targetBackend.name());
}
public static boolean isIgnoredTarget(TargetBackend targetBackend, File file) {
return isIgnoredTarget(targetBackend, file, IGNORE_BACKEND_DIRECTIVE_PREFIX);
}
public static boolean dontRunGeneratedCode(TargetBackend targetBackend, File file) {
List<String> backends = findListWithPrefixes(textWithDirectives(file), "// DONT_RUN_GENERATED_CODE: ");
return backends.contains(targetBackend.name());
@@ -1047,6 +1047,10 @@ public class KotlinTestUtils {
runTest0(test, targetBackend, testDataFile);
}
public static void runTestWithCustomIgnoreDirective(DoTest test, TargetBackend targetBackend, @TestDataFile String testDataFile, String ignoreDirective) throws Exception {
runTest0WithCustomIgnoreDirective(test, targetBackend, testDataFile, ignoreDirective);
}
// In this test runner version, NONE of the parameters are annotated by `TestDataFile`.
// So DevKit will use test name to determine related files in navigation actions, like "Navigate to testdata" and "Related Symbol..."
//
@@ -1056,9 +1060,13 @@ public class KotlinTestUtils {
// * sometimes, for too common/general names, it shows many variants to navigate
// * it adds an additional step for navigation -- you must choose an exact file to navigate
public static void runTest0(DoTest test, TargetBackend targetBackend, String testDataFilePath) throws Exception {
runTest0WithCustomIgnoreDirective(test, targetBackend, testDataFilePath, IGNORE_BACKEND_DIRECTIVE_PREFIX);
}
private static void runTest0WithCustomIgnoreDirective(DoTest test, TargetBackend targetBackend, String testDataFilePath, String ignoreDirective) throws Exception {
File testDataFile = new File(testDataFilePath);
boolean isIgnored = isIgnoredTarget(targetBackend, testDataFile);
boolean isIgnored = isIgnoredTarget(targetBackend, testDataFile, ignoreDirective);
if (DONT_IGNORE_TESTS_WORKING_ON_COMPATIBLE_BACKEND) {
// Only ignore if it is ignored for both backends