Add ability to ignore test for backend w/o checks

It used for the tests from this commit becouse they was failing during setup.
This commit is contained in:
Zalim Bashorov
2016-11-07 19:58:12 +03:00
parent a27572af49
commit af4ec9815b
5 changed files with 27 additions and 28 deletions
@@ -233,10 +233,18 @@ public final class InTextDirectivesUtils {
return backends.isEmpty() || backends.contains(targetBackend.name());
}
public static boolean isIgnoredTarget(TargetBackend targetBackend, File file) {
private static boolean isIgnoredTargetByPrefix(TargetBackend targetBackend, File file, String prefix) {
if (targetBackend == TargetBackend.ANY) return false;
List<String> ignoredBackends = findLinesWithPrefixesRemoved(textWithDirectives(file), "// IGNORE_BACKEND: ");
List<String> ignoredBackends = findLinesWithPrefixesRemoved(textWithDirectives(file), prefix);
return ignoredBackends.contains(targetBackend.name());
}
public static boolean isIgnoredTarget(TargetBackend targetBackend, File file) {
return isIgnoredTargetByPrefix(targetBackend, file, "// IGNORE_BACKEND: ");
}
public static boolean isIgnoredTargetWithoutCheck(TargetBackend targetBackend, File file) {
return isIgnoredTargetByPrefix(targetBackend, file, "// IGNORE_BACKEND_WITHOUT_CHECK: ");
}
}
@@ -30,6 +30,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static org.jetbrains.kotlin.test.InTextDirectivesUtils.isIgnoredTarget;
import static org.jetbrains.kotlin.test.InTextDirectivesUtils.isIgnoredTargetWithoutCheck;
public class SimpleTestMethodModel implements TestMethodModel {
@@ -120,7 +121,7 @@ public class SimpleTestMethodModel implements TestMethodModel {
String relativePath = FileUtil.getRelativePath(rootDir, file.getParentFile());
unescapedName = relativePath + "-" + StringUtil.capitalize(extractedName);
}
return "test" + StringUtil.capitalize(TestGeneratorUtil.escapeForJavaIdentifier(unescapedName));
return (isIgnoredTargetWithoutCheck(targetBackend, file) ? "ignore" : "test") + StringUtil.capitalize(TestGeneratorUtil.escapeForJavaIdentifier(unescapedName));
}
@Override
@@ -1,2 +1,2 @@
// See KT-13691
// IGNORE_BACKEND: JS
// TODO: See KT-13618
// IGNORE_BACKEND_WITHOUT_CHECK: JS
@@ -1,4 +1,4 @@
// TODO Remove this restriction when secondary constructors will be supported in js backend.
// See KT-7798 JS: add support for secondary constructors
// https://youtrack.jetbrains.com/issue/KT-7798
// IGNORE_BACKEND: JS
// IGNORE_BACKEND_WITHOUT_CHECK: JS
@@ -32,6 +32,18 @@ import java.util.regex.Pattern;
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public class CommonDecompiledTextFromJsMetadataTestGenerated extends AbstractCommonDecompiledTextFromJsMetadataTest {
@TestMetadata("LocalClassAsTypeWithArgument")
public void ignoreLocalClassAsTypeWithArgument() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/decompiler/decompiledText/LocalClassAsTypeWithArgument/");
doTest(fileName);
}
@TestMetadata("SecondaryConstructors")
public void ignoreSecondaryConstructors() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/decompiler/decompiledText/SecondaryConstructors/");
doTest(fileName);
}
public void testAllFilesPresentInDecompiledText() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/decompiler/decompiledText"), Pattern.compile("^([^\\.]+)$"), TargetBackend.JS, true);
}
@@ -108,17 +120,6 @@ public class CommonDecompiledTextFromJsMetadataTestGenerated extends AbstractCom
doTest(fileName);
}
@TestMetadata("LocalClassAsTypeWithArgument")
public void testLocalClassAsTypeWithArgument() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/decompiler/decompiledText/LocalClassAsTypeWithArgument/");
try {
doTest(fileName);
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
}
catch (Throwable ignore) {
}
}
@TestMetadata("Modifiers")
public void testModifiers() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/decompiler/decompiledText/Modifiers/");
@@ -137,17 +138,6 @@ public class CommonDecompiledTextFromJsMetadataTestGenerated extends AbstractCom
doTest(fileName);
}
@TestMetadata("SecondaryConstructors")
public void testSecondaryConstructors() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/decompiler/decompiledText/SecondaryConstructors/");
try {
doTest(fileName);
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
}
catch (Throwable ignore) {
}
}
@TestMetadata("SimpleClass")
public void testSimpleClass() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/decompiler/decompiledText/SimpleClass/");