From acb6d2e1966a711c652e0b6c726a2a08ae032cae Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Mon, 18 Jan 2021 15:44:46 +0300 Subject: [PATCH] [Test] Allow facades to return null which indicates that facade can't complete it's job This is needed for cases when test pipeline assumes that some part of pipeline may be unavailable because of errors on previous stage. For example, this may occur in some test which check something on IR but contains backend facade for compiling binary dependencies. In this case testdata with frontend errors is allowed if test has only one module which should not be compiled --- .../tests/org/jetbrains/kotlin/test/TestRunner.kt | 12 ++++++------ .../tests/org/jetbrains/kotlin/test/model/Facades.kt | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/TestRunner.kt b/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/TestRunner.kt index b2b661094eb..7a1332471ff 100644 --- a/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/TestRunner.kt +++ b/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/TestRunner.kt @@ -98,7 +98,7 @@ class TestRunner(private val testConfiguration: TestConfiguration) { if (!frontendKind.shouldRunAnalysis) return val frontendArtifacts: ResultingArtifact.FrontendOutput<*> = testConfiguration.getFacade(SourcesKind, frontendKind) - .transform(module, sourcesArtifact).also { dependencyProvider.registerArtifact(module, it) } + .transform(module, sourcesArtifact)?.also { dependencyProvider.registerArtifact(module, it) } ?: return val frontendHandlers: List> = testConfiguration.getHandlers(frontendKind) for (frontendHandler in frontendHandlers) { withAssertionCatching { @@ -110,7 +110,7 @@ class TestRunner(private val testConfiguration: TestConfiguration) { if (!backendKind.shouldRunAnalysis) return val backendInputInfo = testConfiguration.getFacade(frontendKind, backendKind) - .hackyTransform(module, frontendArtifacts).also { dependencyProvider.registerArtifact(module, it) } + .hackyTransform(module, frontendArtifacts)?.also { dependencyProvider.registerArtifact(module, it) } ?: return val backendHandlers: List> = testConfiguration.getHandlers(backendKind) for (backendHandler in backendHandlers) { @@ -120,9 +120,9 @@ class TestRunner(private val testConfiguration: TestConfiguration) { for (artifactKind in moduleStructure.getTargetArtifactKinds(module)) { if (!artifactKind.shouldRunAnalysis) continue val binaryArtifact = testConfiguration.getFacade(backendKind, artifactKind) - .hackyTransform(module, backendInputInfo).also { + .hackyTransform(module, backendInputInfo)?.also { dependencyProvider.registerArtifact(module, it) - } + } ?: return val binaryHandlers: List> = testConfiguration.getHandlers(artifactKind) for (binaryHandler in binaryHandlers) { @@ -167,7 +167,7 @@ private fun > AnalysisHandler.processModule(module: private fun AbstractTestFacade<*, *>.hackyTransform( module: TestModule, artifact: ResultingArtifact<*> -): ResultingArtifact<*> { +): ResultingArtifact<*>? { @Suppress("UNCHECKED_CAST") return (this as AbstractTestFacade) .transform(module, artifact as ResultingArtifact) @@ -176,7 +176,7 @@ private fun AbstractTestFacade<*, *>.hackyTransform( private fun , O : ResultingArtifact> AbstractTestFacade.transform( module: TestModule, inputArtifact: ResultingArtifact -): O { +): O? { @Suppress("UNCHECKED_CAST") return transform(module, inputArtifact as I) } diff --git a/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/model/Facades.kt b/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/model/Facades.kt index d6f075f226b..dc6fbba6eb2 100644 --- a/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/model/Facades.kt +++ b/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/model/Facades.kt @@ -13,7 +13,7 @@ abstract class AbstractTestFacade, O : ResultingArtifac abstract val inputKind: TestArtifactKind abstract val outputKind: TestArtifactKind - abstract fun transform(module: TestModule, inputArtifact: I): O + abstract fun transform(module: TestModule, inputArtifact: I): O? open val additionalServices: List get() = emptyList()