diff --git a/compiler/fir/analysis-tests/test/org/jetbrains/kotlin/test/FirMetadataLoadingTestSuppressor.kt b/compiler/fir/analysis-tests/test/org/jetbrains/kotlin/test/FirMetadataLoadingTestSuppressor.kt index 4e4ddb51381..4dbeaddb049 100644 --- a/compiler/fir/analysis-tests/test/org/jetbrains/kotlin/test/FirMetadataLoadingTestSuppressor.kt +++ b/compiler/fir/analysis-tests/test/org/jetbrains/kotlin/test/FirMetadataLoadingTestSuppressor.kt @@ -6,15 +6,10 @@ package org.jetbrains.kotlin.test import org.jetbrains.kotlin.test.directives.CodegenTestDirectives -import org.jetbrains.kotlin.test.directives.extractIgnoredDirectivesForTargetBackend import org.jetbrains.kotlin.test.directives.model.DirectivesContainer -import org.jetbrains.kotlin.test.directives.model.SimpleDirective -import org.jetbrains.kotlin.test.directives.model.ValueDirective import org.jetbrains.kotlin.test.model.AfterAnalysisChecker -import org.jetbrains.kotlin.test.model.FrontendKinds -import org.jetbrains.kotlin.test.model.TestModule -import org.jetbrains.kotlin.test.services.* -import org.jetbrains.kotlin.utils.addToStdlib.shouldNotBeCalled +import org.jetbrains.kotlin.test.services.TestServices +import org.jetbrains.kotlin.test.services.moduleStructure class FirMetadataLoadingTestSuppressor(testServices: TestServices) : AfterAnalysisChecker(testServices) { override val directiveContainers: List @@ -22,11 +17,7 @@ class FirMetadataLoadingTestSuppressor(testServices: TestServices) : AfterAnalys override fun suppressIfNeeded(failedAssertions: List): List { val moduleStructure = testServices.moduleStructure - val directive = when (testServices.defaultsProvider.defaultFrontend) { - FrontendKinds.ClassicFrontend -> CodegenTestDirectives.IGNORE_FIR_METADATA_LOADING_K1 - FrontendKinds.FIR -> CodegenTestDirectives.IGNORE_FIR_METADATA_LOADING_K2 - else -> shouldNotBeCalled() - } + val directive = testServices.loadedMetadataSuppressionDirective if (moduleStructure.modules.any { directive in it.directives }) { return if (failedAssertions.isNotEmpty()) { emptyList() @@ -36,4 +27,5 @@ class FirMetadataLoadingTestSuppressor(testServices: TestServices) : AfterAnalys } return failedAssertions } + } diff --git a/compiler/fir/analysis-tests/test/org/jetbrains/kotlin/test/FirMetadataLoadingTestUtils.kt b/compiler/fir/analysis-tests/test/org/jetbrains/kotlin/test/FirMetadataLoadingTestUtils.kt new file mode 100644 index 00000000000..eba80f9c6bb --- /dev/null +++ b/compiler/fir/analysis-tests/test/org/jetbrains/kotlin/test/FirMetadataLoadingTestUtils.kt @@ -0,0 +1,20 @@ +/* + * Copyright 2010-2023 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 org.jetbrains.kotlin.test.directives.CodegenTestDirectives +import org.jetbrains.kotlin.test.directives.model.SimpleDirective +import org.jetbrains.kotlin.test.model.FrontendKinds +import org.jetbrains.kotlin.test.services.TestServices +import org.jetbrains.kotlin.test.services.defaultsProvider +import org.jetbrains.kotlin.utils.addToStdlib.shouldNotBeCalled + +val TestServices.loadedMetadataSuppressionDirective: SimpleDirective + get() = when (defaultsProvider.defaultFrontend) { + FrontendKinds.ClassicFrontend -> CodegenTestDirectives.IGNORE_FIR_METADATA_LOADING_K1 + FrontendKinds.FIR -> CodegenTestDirectives.IGNORE_FIR_METADATA_LOADING_K2 + else -> shouldNotBeCalled() + } \ No newline at end of file diff --git a/compiler/fir/analysis-tests/test/org/jetbrains/kotlin/test/LoadedMetadataDumpHandler.kt b/compiler/fir/analysis-tests/test/org/jetbrains/kotlin/test/LoadedMetadataDumpHandler.kt index f5e637532d6..faa7c9e8c9f 100644 --- a/compiler/fir/analysis-tests/test/org/jetbrains/kotlin/test/LoadedMetadataDumpHandler.kt +++ b/compiler/fir/analysis-tests/test/org/jetbrains/kotlin/test/LoadedMetadataDumpHandler.kt @@ -41,6 +41,7 @@ class LoadedMetadataDumpHandler(testServices: TestServices) : JvmBinaryArtifactH private val dumper: MultiModuleInfoDumper = MultiModuleInfoDumper() override fun processModule(module: TestModule, info: BinaryArtifacts.Jvm) { + if (testServices.loadedMetadataSuppressionDirective in module.directives) return val emptyModule = TestModule( name = "empty", JvmPlatforms.defaultJvmPlatform, TargetBackend.JVM_IR, FrontendKinds.FIR, BackendKinds.IrBackend, ArtifactKinds.Jvm, files = emptyList(),