From 64ce307f7faa1429780855727f3a5ed7ec55ba95 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Mon, 14 Dec 2020 12:27:46 +0300 Subject: [PATCH] [TEST] Drop mechanism for muting tests with .mute files This mechanism is deprecated and replaced with muting in database (.csv files) --- ...ntalJsKlibCompilerRunnerTestGenerated.java | 7 - .../kotlin/test/KotlinTestUtils.java | 2 +- .../org/jetbrains/kotlin/test/muteWithFile.kt | 129 ------------------ .../generators/model/AnnotationModel.kt | 4 - .../kotlin/generators/tests/GenerateTests.kt | 9 +- .../generators/tests/GenerateTests.kt.as41 | 9 +- .../generators/tests/GenerateTests.kt.as42 | 7 +- ...igateJavaToLibrarySourceTestGenerated.java | 2 - .../NavigateToLibrarySourceTestGenerated.java | 2 - ...ateToLibrarySourceTestWithJSGenerated.java | 2 - 10 files changed, 12 insertions(+), 161 deletions(-) delete mode 100644 compiler/tests-common/tests/org/jetbrains/kotlin/test/muteWithFile.kt diff --git a/compiler/incremental-compilation-impl/test/org/jetbrains/kotlin/incremental/IncrementalJsKlibCompilerRunnerTestGenerated.java b/compiler/incremental-compilation-impl/test/org/jetbrains/kotlin/incremental/IncrementalJsKlibCompilerRunnerTestGenerated.java index a2ebc94ad72..b34e6388890 100644 --- a/compiler/incremental-compilation-impl/test/org/jetbrains/kotlin/incremental/IncrementalJsKlibCompilerRunnerTestGenerated.java +++ b/compiler/incremental-compilation-impl/test/org/jetbrains/kotlin/incremental/IncrementalJsKlibCompilerRunnerTestGenerated.java @@ -8,7 +8,6 @@ package org.jetbrains.kotlin.incremental; import com.intellij.testFramework.TestDataPath; import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; import org.jetbrains.kotlin.test.KotlinTestUtils; -import org.jetbrains.kotlin.test.MuteExtraSuffix; import org.jetbrains.kotlin.test.TestMetadata; import org.junit.runner.RunWith; @@ -21,7 +20,6 @@ import java.util.regex.Pattern; public class IncrementalJsKlibCompilerRunnerTestGenerated extends AbstractIncrementalJsKlibCompilerRunnerTest { @TestMetadata("jps-plugin/testData/incremental/pureKotlin") @TestDataPath("$PROJECT_ROOT") - @MuteExtraSuffix(".jsklib") @RunWith(JUnit3RunnerWithInners.class) public static class PureKotlin extends AbstractIncrementalJsKlibCompilerRunnerTest { private void runTest(String testDataFilePath) throws Exception { @@ -630,7 +628,6 @@ public class IncrementalJsKlibCompilerRunnerTestGenerated extends AbstractIncrem @TestMetadata("jps-plugin/testData/incremental/classHierarchyAffected") @TestDataPath("$PROJECT_ROOT") - @MuteExtraSuffix(".jsklib") @RunWith(JUnit3RunnerWithInners.class) public static class ClassHierarchyAffected extends AbstractIncrementalJsKlibCompilerRunnerTest { private void runTest(String testDataFilePath) throws Exception { @@ -844,7 +841,6 @@ public class IncrementalJsKlibCompilerRunnerTestGenerated extends AbstractIncrem @TestMetadata("jps-plugin/testData/incremental/js") @TestDataPath("$PROJECT_ROOT") - @MuteExtraSuffix(".jsklib") @RunWith(JUnit3RunnerWithInners.class) public static class Js extends AbstractIncrementalJsKlibCompilerRunnerTest { private void runTest(String testDataFilePath) throws Exception { @@ -862,7 +858,6 @@ public class IncrementalJsKlibCompilerRunnerTestGenerated extends AbstractIncrem @TestMetadata("jps-plugin/testData/incremental/js/friendsModuleDisabled") @TestDataPath("$PROJECT_ROOT") - @MuteExtraSuffix(".jsklib") @RunWith(JUnit3RunnerWithInners.class) public static class FriendsModuleDisabled extends AbstractIncrementalJsKlibCompilerRunnerTest { private void runTest(String testDataFilePath) throws Exception { @@ -880,7 +875,6 @@ public class IncrementalJsKlibCompilerRunnerTestGenerated extends AbstractIncrem @TestMetadata("jps-plugin/testData/incremental/js/friendsModuleDisabled/internalInlineFunctionIsChanged") @TestDataPath("$PROJECT_ROOT") - @MuteExtraSuffix(".jsklib") @RunWith(JUnit3RunnerWithInners.class) public static class InternalInlineFunctionIsChanged extends AbstractIncrementalJsKlibCompilerRunnerTest { private void runTest(String testDataFilePath) throws Exception { @@ -895,7 +889,6 @@ public class IncrementalJsKlibCompilerRunnerTestGenerated extends AbstractIncrem @TestMetadata("jps-plugin/testData/incremental/js/inlineFunctionLocalDeclarationChanges") @TestDataPath("$PROJECT_ROOT") - @MuteExtraSuffix(".jsklib") @RunWith(JUnit3RunnerWithInners.class) public static class InlineFunctionLocalDeclarationChanges extends AbstractIncrementalJsKlibCompilerRunnerTest { private void runTest(String testDataFilePath) throws Exception { diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java b/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java index fd1d1ba3761..dcf3e7f19b1 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java @@ -599,7 +599,7 @@ public class KotlinTestUtils { return; } } - MuteWithFileKt.testWithMuteInFile(test, testCase).invoke(testDataFilePath); + test.invoke(testDataFilePath); } private static boolean isRunTestOverridden(TestCase testCase) { diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/test/muteWithFile.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/test/muteWithFile.kt deleted file mode 100644 index d7d6095f271..00000000000 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/test/muteWithFile.kt +++ /dev/null @@ -1,129 +0,0 @@ -/* - * 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.test - -import junit.framework.TestCase -import org.jetbrains.kotlin.test.KotlinTestUtils.DoTest -import org.junit.Assert -import java.io.File - -private val RUN_MUTED_TESTS = java.lang.Boolean.getBoolean("org.jetbrains.kotlin.run.muted.tests") -private val AUTOMATICALLY_MUTE_FAILED_TESTS_WITH_CONTENT: String? = null -private val AUTOMATICALLY_GENERATE_FAIL_FILE_FOR_FAILED_TESTS: Boolean = false - -annotation class MuteExtraSuffix(val value: String = "") - -@Throws(Exception::class) -fun testWithMuteInFile(test: DoTest, testCase: TestCase?): DoTest { - val extraSuffix = testCase?.javaClass?.getAnnotation(MuteExtraSuffix::class.java)?.value ?: "" - return testWithMuteInFile(test, extraSuffix) -} - -@Throws(Exception::class) -fun testWithMuteInFile(test: DoTest, extraSuffix: String): DoTest { - return object : DoTest { - override fun invoke(filePath: String) { - val testDataFile = File(filePath) - - val isMutedWithFile = isMutedWithFile(testDataFile, extraSuffix) - if (isMutedWithFile && !RUN_MUTED_TESTS) { - System.err.println("MUTED TEST: $filePath") - return - } - - val failFile = failFile(testDataFile, extraSuffix) - val hasFailFile = failFile != null - - try { - test.invoke(filePath) - } catch (e: Throwable) { - if (checkFailFile(e, testDataFile, extraSuffix)) { - System.err.println("MUTED TEST (FAIL): $filePath") - return - } - - if (!isMutedWithFile && !hasFailFile && AUTOMATICALLY_MUTE_FAILED_TESTS_WITH_CONTENT != null) { - createMuteFile(testDataFile, extraSuffix, AUTOMATICALLY_MUTE_FAILED_TESTS_WITH_CONTENT) - } - throw e - } - - Assert.assertNull("Test is good but there is a fail file", failFile) - } - } -} - -private fun isMutedWithFile(testPathFile: File, extraSuffix: String): Boolean { - return muteFile(testPathFile, extraSuffix) != null -} - -private fun createMuteFile(testDataFile: File, extraSuffix: String, text: String) { - require(text.isNotEmpty()) { "Mute text must not be empty" } - - muteFileNoCheck(testDataFile, extraSuffix).writeText(text) -} - -private fun rawFileNoChecks(testPathFile: File, extraSuffix: String, suffix: String): File { - return when { - testPathFile.isDirectory -> - File(testPathFile, "${testPathFile.name}$extraSuffix$suffix") - else -> - File("${testPathFile.path}$extraSuffix$suffix") - } -} - -private fun muteFileNoCheck(testPathFile: File, extraSuffix: String): File { - return rawFileNoChecks(testPathFile, extraSuffix, ".mute") -} - -private fun failFileNoCheck(testPathFile: File, extraSuffix: String): File { - return rawFileNoChecks(testPathFile, extraSuffix, ".fail") -} - -private fun muteFile(testPathFile: File, extraSuffix: String): File? { - val muteFile = muteFileNoCheck(testPathFile, extraSuffix) - - if (muteFile.exists() && muteFile.isFile) { - return muteFile - } - - return null -} - -private fun failFile(testDataFile: File, extraSuffix: String): File? { - val failFile = failFileNoCheck(testDataFile, extraSuffix) - - if (!failFile.exists() || !failFile.isFile) { - return null - } - - return failFile -} - -private fun failMessage(failure: Throwable): String { - val cause = failure.cause - return failure.message + - if (cause != null) { - "\n" + cause - } else { - "" - } -} - -private fun checkFailFile(failure: Throwable, testDataFile: File, extraSuffix: String): Boolean { - val failFile = failFile(testDataFile, extraSuffix) - - if (failFile == null) { - if (AUTOMATICALLY_GENERATE_FAIL_FILE_FOR_FAILED_TESTS) { - failFileNoCheck(testDataFile, extraSuffix).writeText(failMessage(failure)) - } - - return false - } - - KotlinTestUtils.assertEqualsToFile(failFile, failMessage(failure)) - return true -} \ No newline at end of file diff --git a/generators/test-generator/tests/org/jetbrains/kotlin/generators/model/AnnotationModel.kt b/generators/test-generator/tests/org/jetbrains/kotlin/generators/model/AnnotationModel.kt index 79dfe7945b6..5410ea57abc 100644 --- a/generators/test-generator/tests/org/jetbrains/kotlin/generators/model/AnnotationModel.kt +++ b/generators/test-generator/tests/org/jetbrains/kotlin/generators/model/AnnotationModel.kt @@ -5,7 +5,6 @@ package org.jetbrains.kotlin.generators.model -import org.jetbrains.kotlin.test.MuteExtraSuffix import org.jetbrains.kotlin.utils.Printer class AnnotationModel( @@ -17,6 +16,3 @@ class AnnotationModel( p.print("@${annotation.simpleName}($argumentsString)") } } - -fun muteExtraSuffix(suffix: String) = AnnotationModel(MuteExtraSuffix::class.java, arguments = listOf(suffix)) - diff --git a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt index 9a4fe629763..2ee65a13b1d 100644 --- a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt +++ b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt @@ -26,7 +26,6 @@ import org.jetbrains.kotlin.formatter.AbstractFormatterTest import org.jetbrains.kotlin.formatter.AbstractTypingIndentationTestBase import org.jetbrains.kotlin.generators.TestGroup import org.jetbrains.kotlin.generators.generateTestGroupSuite -import org.jetbrains.kotlin.generators.model.muteExtraSuffix import org.jetbrains.kotlin.generators.util.TestGeneratorUtil.KT_OR_KTS import org.jetbrains.kotlin.generators.util.TestGeneratorUtil.KT_OR_KTS_WITHOUT_DOTS_IN_NAME import org.jetbrains.kotlin.generators.util.TestGeneratorUtil.KT_WITHOUT_DOTS_IN_NAME @@ -384,15 +383,15 @@ fun main(args: Array) { model("navigation/gotoSymbol", testMethod = "doSymbolTest") } - testClass(annotations = listOf(muteExtraSuffix(".libsrc"))) { + testClass() { model("decompiler/navigation/usercode") } - testClass(annotations = listOf(muteExtraSuffix(".libsrc"))) { + testClass() { model("decompiler/navigation/userJavaCode", pattern = "^(.+)\\.java$") } - testClass(annotations = listOf(muteExtraSuffix(".libsrcjs"))) { + testClass() { model("decompiler/navigation/usercode", testClassName = "UsercodeWithJSModule") } @@ -1528,7 +1527,7 @@ fun main(args: Array) { model("incremental/js", extension = null, excludeParentDirs = true) } - testClass(annotations = listOf(muteExtraSuffix(".jsklib"))) { + testClass() { // IC of sealed interfaces are not supported in JS model("incremental/pureKotlin", extension = null, recursive = false, excludedPattern = "^sealed.*") model("incremental/classHierarchyAffected", extension = null, recursive = false) diff --git a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt.as41 b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt.as41 index bf16f61fa92..8f42e940994 100644 --- a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt.as41 +++ b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt.as41 @@ -31,7 +31,6 @@ import org.jetbrains.kotlin.formatter.AbstractFormatterTest import org.jetbrains.kotlin.formatter.AbstractTypingIndentationTestBase import org.jetbrains.kotlin.generators.TestGroup import org.jetbrains.kotlin.generators.generateTestGroupSuite -import org.jetbrains.kotlin.generators.model.muteExtraSuffix import org.jetbrains.kotlin.generators.util.TestGeneratorUtil.KT_OR_KTS import org.jetbrains.kotlin.generators.util.TestGeneratorUtil.KT_OR_KTS_WITHOUT_DOTS_IN_NAME import org.jetbrains.kotlin.generators.util.TestGeneratorUtil.KT_WITHOUT_DOTS_IN_NAME @@ -306,16 +305,16 @@ fun main(args: Array) { model("navigation/gotoSymbol", testMethod = "doSymbolTest") } - testClass(annotations = listOf(muteExtraSuffix(".libsrc"))) { + testClass() { model("decompiler/navigation/usercode") } - testClass(annotations = listOf(muteExtraSuffix(".libsrc"))) { + testClass() { model("decompiler/navigation/userJavaCode", pattern = "^(.+)\\.java$") } - testClass(annotations = listOf(muteExtraSuffix(".libsrcjs"))) { - model("decompiler/navigation/usercode", testClassName ="UsercodeWithJSModule") + testClass() { + model("decompiler/navigation/usercode", testClassName = "UsercodeWithJSModule") } testClass { diff --git a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt.as42 b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt.as42 index 03b01f09375..8d15228c1a8 100644 --- a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt.as42 +++ b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt.as42 @@ -31,7 +31,6 @@ import org.jetbrains.kotlin.formatter.AbstractFormatterTest import org.jetbrains.kotlin.formatter.AbstractTypingIndentationTestBase import org.jetbrains.kotlin.generators.TestGroup import org.jetbrains.kotlin.generators.generateTestGroupSuite -import org.jetbrains.kotlin.generators.model.muteExtraSuffix import org.jetbrains.kotlin.generators.util.TestGeneratorUtil.KT_OR_KTS import org.jetbrains.kotlin.generators.util.TestGeneratorUtil.KT_OR_KTS_WITHOUT_DOTS_IN_NAME import org.jetbrains.kotlin.generators.util.TestGeneratorUtil.KT_WITHOUT_DOTS_IN_NAME @@ -302,15 +301,15 @@ fun main(args: Array) { model("navigation/gotoSymbol", testMethod = "doSymbolTest") } - testClass(annotations = listOf(muteExtraSuffix(".libsrc"))) { + testClass() { model("decompiler/navigation/usercode") } - testClass(annotations = listOf(muteExtraSuffix(".libsrc"))) { + testClass() { model("decompiler/navigation/userJavaCode", pattern = "^(.+)\\.java$") } - testClass(annotations = listOf(muteExtraSuffix(".libsrcjs"))) { + testClass() { model("decompiler/navigation/usercode", testClassName ="UsercodeWithJSModule") } diff --git a/idea/tests/org/jetbrains/kotlin/idea/decompiler/navigation/NavigateJavaToLibrarySourceTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/decompiler/navigation/NavigateJavaToLibrarySourceTestGenerated.java index 3b692be914d..d4651f82671 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/decompiler/navigation/NavigateJavaToLibrarySourceTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/decompiler/navigation/NavigateJavaToLibrarySourceTestGenerated.java @@ -8,7 +8,6 @@ package org.jetbrains.kotlin.idea.decompiler.navigation; import com.intellij.testFramework.TestDataPath; import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; import org.jetbrains.kotlin.test.KotlinTestUtils; -import org.jetbrains.kotlin.test.MuteExtraSuffix; import org.jetbrains.kotlin.test.TestMetadata; import org.junit.runner.RunWith; @@ -19,7 +18,6 @@ import java.util.regex.Pattern; @SuppressWarnings("all") @TestMetadata("idea/testData/decompiler/navigation/userJavaCode") @TestDataPath("$PROJECT_ROOT") -@MuteExtraSuffix(".libsrc") @RunWith(JUnit3RunnerWithInners.class) public class NavigateJavaToLibrarySourceTestGenerated extends AbstractNavigateJavaToLibrarySourceTest { private void runTest(String testDataFilePath) throws Exception { diff --git a/idea/tests/org/jetbrains/kotlin/idea/decompiler/navigation/NavigateToLibrarySourceTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/decompiler/navigation/NavigateToLibrarySourceTestGenerated.java index f90b0c6acb1..15cefa3c1ab 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/decompiler/navigation/NavigateToLibrarySourceTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/decompiler/navigation/NavigateToLibrarySourceTestGenerated.java @@ -8,7 +8,6 @@ package org.jetbrains.kotlin.idea.decompiler.navigation; import com.intellij.testFramework.TestDataPath; import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; import org.jetbrains.kotlin.test.KotlinTestUtils; -import org.jetbrains.kotlin.test.MuteExtraSuffix; import org.jetbrains.kotlin.test.TestMetadata; import org.junit.runner.RunWith; @@ -19,7 +18,6 @@ import java.util.regex.Pattern; @SuppressWarnings("all") @TestMetadata("idea/testData/decompiler/navigation/usercode") @TestDataPath("$PROJECT_ROOT") -@MuteExtraSuffix(".libsrc") @RunWith(JUnit3RunnerWithInners.class) public class NavigateToLibrarySourceTestGenerated extends AbstractNavigateToLibrarySourceTest { private void runTest(String testDataFilePath) throws Exception { diff --git a/idea/tests/org/jetbrains/kotlin/idea/decompiler/navigation/NavigateToLibrarySourceTestWithJSGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/decompiler/navigation/NavigateToLibrarySourceTestWithJSGenerated.java index 5ea7bf94c9e..ee52643950d 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/decompiler/navigation/NavigateToLibrarySourceTestWithJSGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/decompiler/navigation/NavigateToLibrarySourceTestWithJSGenerated.java @@ -8,7 +8,6 @@ package org.jetbrains.kotlin.idea.decompiler.navigation; import com.intellij.testFramework.TestDataPath; import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; import org.jetbrains.kotlin.test.KotlinTestUtils; -import org.jetbrains.kotlin.test.MuteExtraSuffix; import org.jetbrains.kotlin.test.TestMetadata; import org.junit.runner.RunWith; @@ -19,7 +18,6 @@ import java.util.regex.Pattern; @SuppressWarnings("all") @TestMetadata("idea/testData/decompiler/navigation/usercode") @TestDataPath("$PROJECT_ROOT") -@MuteExtraSuffix(".libsrcjs") @RunWith(JUnit3RunnerWithInners.class) public class NavigateToLibrarySourceTestWithJSGenerated extends AbstractNavigateToLibrarySourceTestWithJS { private void runTest(String testDataFilePath) throws Exception {