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).

This commit is contained in:
Anton Bannykh
2016-11-18 20:23:01 +03:00
parent 85a775375a
commit 2bec54924f
2 changed files with 7 additions and 20 deletions
@@ -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<String> 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();
@@ -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);
}
}