From 2bec54924f6424d74fdb6d2e9129af4976edc744 Mon Sep 17 00:00:00 2001 From: Anton Bannykh Date: Fri, 18 Nov 2016 20:23:01 +0300 Subject: [PATCH] Android tests: use directives from tests-common to determine if the test is supposed to pass on JVM (adds support for IGNORE_BACKEND and IGNORE_BACKEND_WItHOUT_CHECK" directives). --- .../tests/CodegenTestsOnAndroidGenerator.java | 22 ++----------------- .../kotlin/test/InTextDirectivesUtils.java | 5 +++++ 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/CodegenTestsOnAndroidGenerator.java b/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/CodegenTestsOnAndroidGenerator.java index ba9aa1a9c22..3a9c1456574 100644 --- a/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/CodegenTestsOnAndroidGenerator.java +++ b/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/CodegenTestsOnAndroidGenerator.java @@ -35,10 +35,7 @@ import org.jetbrains.kotlin.idea.KotlinFileType; import org.jetbrains.kotlin.load.java.JvmAbi; import org.jetbrains.kotlin.name.FqName; import org.jetbrains.kotlin.psi.KtFile; -import org.jetbrains.kotlin.test.ConfigurationKind; -import org.jetbrains.kotlin.test.InTextDirectivesUtils; -import org.jetbrains.kotlin.test.KotlinTestUtils; -import org.jetbrains.kotlin.test.TestJdkKind; +import org.jetbrains.kotlin.test.*; import org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase; import org.jetbrains.kotlin.utils.Printer; import org.junit.Assert; @@ -243,7 +240,7 @@ public class CodegenTestsOnAndroidGenerator extends KtUsefulTestCase { else { String fullFileText = FileUtil.loadFile(file, true); - if (!hasJvmBackendTarget(fullFileText)) { + if (!InTextDirectivesUtils.isPassingTarget(TargetBackend.JVM, file)) { continue; } @@ -272,21 +269,6 @@ public class CodegenTestsOnAndroidGenerator extends KtUsefulTestCase { return text.contains("fun box()"); } - private static boolean hasJvmBackendTarget(String text) { - List backends = InTextDirectivesUtils.findLinesWithPrefixesRemoved(text, "// TARGET_BACKEND: "); - if (backends.isEmpty()) { - return true; - } - - for (String backend : backends) { - if (backend.equals("JVM")) { - return true; - } - } - - return false; - } - private static void generateTestMethod(Printer p, String testName, String className, String filePath) { p.println("public void test" + testName + "() throws Exception {"); p.pushIndent(); diff --git a/compiler/tests-common/org/jetbrains/kotlin/test/InTextDirectivesUtils.java b/compiler/tests-common/org/jetbrains/kotlin/test/InTextDirectivesUtils.java index 751518077e8..5b47b65c4d4 100644 --- a/compiler/tests-common/org/jetbrains/kotlin/test/InTextDirectivesUtils.java +++ b/compiler/tests-common/org/jetbrains/kotlin/test/InTextDirectivesUtils.java @@ -247,4 +247,9 @@ public final class InTextDirectivesUtils { public static boolean isIgnoredTargetWithoutCheck(TargetBackend targetBackend, File file) { return isIgnoredTargetByPrefix(targetBackend, file, "// IGNORE_BACKEND_WITHOUT_CHECK: "); } + + // Whether the target test is supposed to pass successfully on targetBackend + public static boolean isPassingTarget(TargetBackend targetBackend, File file) { + return isCompatibleTarget(targetBackend, file) && !isIgnoredTarget(targetBackend, file) && !isIgnoredTargetWithoutCheck(targetBackend, file); + } }