diff --git a/compiler/testData/codegen/box/klib/kt33411.kt b/compiler/testData/codegen/box/klib/kt33411.kt index e8f9d18450d..aacd2113da4 100644 --- a/compiler/testData/codegen/box/klib/kt33411.kt +++ b/compiler/testData/codegen/box/klib/kt33411.kt @@ -1,5 +1,10 @@ // IGNORE_NATIVE: cacheMode=STATIC_EVERYWHERE && target=linux_x64 // IGNORE_NATIVE: cacheMode=STATIC_PER_FILE_EVERYWHERE && target=linux_x64 +// IGNORE_BACKEND_K1: JVM, JVM_IR +// DONT_CHECK_IGNORED +// LightAnalysisModeTestGenerated passes because it doesn't compile the body of function `box` actually + +// ISSUE: KT-33411, KT-66338 // MODULE: m1 // FILE: m1.kt @@ -13,4 +18,8 @@ fun getK() = "K" // MODULE: main(m1)(m2) // FILE: main.kt -fun box() = getO() + getK() + +fun box(): String { + f() + return getO() + getK() +} 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 82be53d66c6..b0babee2277 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java @@ -63,8 +63,7 @@ import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; -import static org.jetbrains.kotlin.test.InTextDirectivesUtils.IGNORE_BACKEND_DIRECTIVE_PREFIXES; -import static org.jetbrains.kotlin.test.InTextDirectivesUtils.isIgnoredTarget; +import static org.jetbrains.kotlin.test.InTextDirectivesUtils.*; public class KotlinTestUtils { public static String TEST_MODULE_NAME = "test-module"; @@ -83,6 +82,13 @@ public class KotlinTestUtils { private static final Pattern DIRECTIVE_PATTERN = Pattern.compile("^//\\s*[!]?([A-Z_0-9]+)(:[ \\t]*(.*))?$", Pattern.MULTILINE); + /** + * This directive removes checks if ignored test actually passes or not + * It is very hacky and supposed to be use only in cases when some test passes in one configuration and fails in the other, + * and both those configurations share the same ignore directive + */ + private static final String DONT_CHECK_IGNORED = "DONT_CHECK_IGNORED"; + private KotlinTestUtils() { } @@ -571,7 +577,9 @@ public class KotlinTestUtils { return; } - if (isIgnored) { + boolean dontCheckIgnored = InTextDirectivesUtils.isDirectiveDefined(textWithDirectives(testDataFile), DONT_CHECK_IGNORED); + + if (isIgnored && !dontCheckIgnored) { StringBuilder directivesToRemove = new StringBuilder(); if (AUTOMATICALLY_UNMUTE_PASSED_TESTS) { for (String ignoreDirective: ignoreDirectives){ diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 721a3172f6f..72e55b2727e 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -30865,6 +30865,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) public static class Klib extends AbstractLightAnalysisModeTest { + @TestMetadata("kt33411.kt") + public void ignoreKt33411() { + runTest("compiler/testData/codegen/box/klib/kt33411.kt"); + } + private void runTest(String testDataFilePath) { KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); } @@ -30872,11 +30877,6 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes public void testAllFilesPresentInKlib() { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/klib"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } - - @TestMetadata("kt33411.kt") - public void testKt33411() { - runTest("compiler/testData/codegen/box/klib/kt33411.kt"); - } } @TestMetadata("compiler/testData/codegen/box/ktype")