[Tests] Fix reporting when FirLoadCompiledKotlinTest can be unmuted

This commit is contained in:
Kirill Rakhman
2023-05-09 15:55:37 +02:00
committed by Space Team
parent c129e91bd6
commit 8dad097841
3 changed files with 25 additions and 12 deletions
@@ -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<DirectivesContainer>
@@ -22,11 +17,7 @@ class FirMetadataLoadingTestSuppressor(testServices: TestServices) : AfterAnalys
override fun suppressIfNeeded(failedAssertions: List<WrappedException>): List<WrappedException> {
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
}
}
@@ -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()
}
@@ -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(),