From af4ec9815bdc4514a35df1a6904464a399ae1dd0 Mon Sep 17 00:00:00 2001 From: Zalim Bashorov Date: Mon, 7 Nov 2016 19:58:12 +0300 Subject: [PATCH] Add ability to ignore test for backend w/o checks It used for the tests from this commit becouse they was failing during setup. --- .../kotlin/test/InTextDirectivesUtils.java | 12 +++++-- .../generator/SimpleTestMethodModel.java | 3 +- .../directives.txt | 4 +-- .../SecondaryConstructors/directives.txt | 2 +- ...mpiledTextFromJsMetadataTestGenerated.java | 34 +++++++------------ 5 files changed, 27 insertions(+), 28 deletions(-) diff --git a/compiler/tests-common/org/jetbrains/kotlin/test/InTextDirectivesUtils.java b/compiler/tests-common/org/jetbrains/kotlin/test/InTextDirectivesUtils.java index bc7dc88bb88..751518077e8 100644 --- a/compiler/tests-common/org/jetbrains/kotlin/test/InTextDirectivesUtils.java +++ b/compiler/tests-common/org/jetbrains/kotlin/test/InTextDirectivesUtils.java @@ -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 ignoredBackends = findLinesWithPrefixesRemoved(textWithDirectives(file), "// IGNORE_BACKEND: "); + List 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: "); + } } diff --git a/generators/src/org/jetbrains/kotlin/generators/tests/generator/SimpleTestMethodModel.java b/generators/src/org/jetbrains/kotlin/generators/tests/generator/SimpleTestMethodModel.java index 4502f8347ee..465215b9d5f 100644 --- a/generators/src/org/jetbrains/kotlin/generators/tests/generator/SimpleTestMethodModel.java +++ b/generators/src/org/jetbrains/kotlin/generators/tests/generator/SimpleTestMethodModel.java @@ -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 diff --git a/idea/testData/decompiler/decompiledText/LocalClassAsTypeWithArgument/directives.txt b/idea/testData/decompiler/decompiledText/LocalClassAsTypeWithArgument/directives.txt index 001ce78902f..bb1ac5093cc 100644 --- a/idea/testData/decompiler/decompiledText/LocalClassAsTypeWithArgument/directives.txt +++ b/idea/testData/decompiler/decompiledText/LocalClassAsTypeWithArgument/directives.txt @@ -1,2 +1,2 @@ -// See KT-13691 -// IGNORE_BACKEND: JS +// TODO: See KT-13618 +// IGNORE_BACKEND_WITHOUT_CHECK: JS diff --git a/idea/testData/decompiler/decompiledText/SecondaryConstructors/directives.txt b/idea/testData/decompiler/decompiledText/SecondaryConstructors/directives.txt index 86f1d1a5aae..c700876b606 100644 --- a/idea/testData/decompiler/decompiledText/SecondaryConstructors/directives.txt +++ b/idea/testData/decompiler/decompiledText/SecondaryConstructors/directives.txt @@ -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 diff --git a/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/CommonDecompiledTextFromJsMetadataTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/CommonDecompiledTextFromJsMetadataTestGenerated.java index 00f57b182bf..b29bcbcda64 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/CommonDecompiledTextFromJsMetadataTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/CommonDecompiledTextFromJsMetadataTestGenerated.java @@ -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/");