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 7c60db6d9b8..e5f6dba88e4 100644 --- a/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/TestRunner.kt +++ b/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/TestRunner.kt @@ -60,8 +60,14 @@ class TestRunner(private val testConfiguration: TestConfiguration) { } catch (e: Throwable) { failedException = e } + for (handler in testConfiguration.getAllHandlers()) { - withAssertionCatching { handler.processAfterAllModules(failedAssertions.isNotEmpty()) } + withAssertionCatching { + val thereWasAnException = failedException != null || failedAssertions.isNotEmpty() + if (handler.shouldRun(thereWasAnException)) { + handler.processAfterAllModules(thereWasAnException) + } + } } if (testConfiguration.metaInfoHandlerEnabled) { withAssertionCatching(insertExceptionInStart = true) { @@ -103,7 +109,9 @@ class TestRunner(private val testConfiguration: TestConfiguration) { val frontendHandlers: List> = testConfiguration.getHandlers(frontendKind) for (frontendHandler in frontendHandlers) { withAssertionCatching { - frontendHandler.hackyProcess(module, frontendArtifacts) + if (frontendHandler.shouldRun(failedAssertions.isNotEmpty())) { + frontendHandler.hackyProcess(module, frontendArtifacts) + } } } @@ -115,7 +123,11 @@ class TestRunner(private val testConfiguration: TestConfiguration) { val backendHandlers: List> = testConfiguration.getHandlers(backendKind) for (backendHandler in backendHandlers) { - withAssertionCatching { backendHandler.hackyProcess(module, backendInputInfo) } + withAssertionCatching { + if (backendHandler.shouldRun(failedAssertions.isNotEmpty())) { + backendHandler.hackyProcess(module, backendInputInfo) + } + } } for (artifactKind in moduleStructure.getTargetArtifactKinds(module)) { @@ -127,7 +139,11 @@ class TestRunner(private val testConfiguration: TestConfiguration) { val binaryHandlers: List> = testConfiguration.getHandlers(artifactKind) for (binaryHandler in binaryHandlers) { - withAssertionCatching { binaryHandler.hackyProcess(module, binaryArtifact) } + withAssertionCatching { + if (binaryHandler.shouldRun(failedAssertions.isNotEmpty())) { + binaryHandler.hackyProcess(module, binaryArtifact) + } + } } } } @@ -143,6 +159,10 @@ class TestRunner(private val testConfiguration: TestConfiguration) { } } } + + private fun AnalysisHandler<*>.shouldRun(thereWasAnException: Boolean): Boolean { + return !(doNotRunIfThereWerePreviousFailures && thereWasAnException) + } } // ---------------------------------------------------------------------------------------------------------------- diff --git a/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/model/AnalysisHandler.kt b/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/model/AnalysisHandler.kt index cb394e4da06..a9b7a4907da 100644 --- a/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/model/AnalysisHandler.kt +++ b/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/model/AnalysisHandler.kt @@ -11,7 +11,10 @@ import org.jetbrains.kotlin.test.services.ServiceRegistrationData import org.jetbrains.kotlin.test.services.TestServices import org.jetbrains.kotlin.test.services.assertions -abstract class AnalysisHandler>(val testServices: TestServices) { +abstract class AnalysisHandler>( + val testServices: TestServices, + val doNotRunIfThereWerePreviousFailures: Boolean +) { protected val assertions: Assertions get() = testServices.assertions @@ -30,15 +33,18 @@ abstract class AnalysisHandler>(val testServices: TestS abstract class FrontendOutputHandler>( testServices: TestServices, - override val artifactKind: FrontendKind -) : AnalysisHandler(testServices) + override val artifactKind: FrontendKind, + doNotRunIfThereWerePreviousFailures: Boolean +) : AnalysisHandler(testServices, doNotRunIfThereWerePreviousFailures) abstract class BackendInputHandler>( testServices: TestServices, - override val artifactKind: BackendKind -) : AnalysisHandler(testServices) + override val artifactKind: BackendKind, + doNotRunIfThereWerePreviousFailures: Boolean +) : AnalysisHandler(testServices, doNotRunIfThereWerePreviousFailures) abstract class BinaryArtifactHandler>( testServices: TestServices, - override val artifactKind: BinaryKind -) : AnalysisHandler(testServices) + override val artifactKind: BinaryKind, + doNotRunIfThereWerePreviousFailures: Boolean +) : AnalysisHandler(testServices, doNotRunIfThereWerePreviousFailures) diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/AbstractIrHandler.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/AbstractIrHandler.kt index bc259a5f85b..ddfb1a5606d 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/AbstractIrHandler.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/AbstractIrHandler.kt @@ -10,4 +10,7 @@ import org.jetbrains.kotlin.test.model.BackendInputHandler import org.jetbrains.kotlin.test.model.BackendKinds import org.jetbrains.kotlin.test.services.TestServices -abstract class AbstractIrHandler(testServices: TestServices) : BackendInputHandler(testServices, BackendKinds.IrBackend) +abstract class AbstractIrHandler( + testServices: TestServices, + doNotRunIfThereWerePreviousFailures: Boolean = false +) : BackendInputHandler(testServices, BackendKinds.IrBackend, doNotRunIfThereWerePreviousFailures) diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/BinaryArtifactHandlers.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/BinaryArtifactHandlers.kt index 930fd0967c7..2ae59632869 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/BinaryArtifactHandlers.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/BinaryArtifactHandlers.kt @@ -11,13 +11,28 @@ import org.jetbrains.kotlin.test.model.BinaryArtifacts import org.jetbrains.kotlin.test.services.TestServices abstract class JvmBinaryArtifactHandler( - testServices: TestServices -) : BinaryArtifactHandler(testServices, ArtifactKinds.Jvm) + testServices: TestServices, + doNotRunIfThereWerePreviousFailures: Boolean = false +) : BinaryArtifactHandler( + testServices, + ArtifactKinds.Jvm, + doNotRunIfThereWerePreviousFailures +) abstract class JsBinaryArtifactHandler( - testServices: TestServices -) : BinaryArtifactHandler(testServices, ArtifactKinds.Js) + testServices: TestServices, + doNotRunIfThereWerePreviousFailures: Boolean = false +) : BinaryArtifactHandler( + testServices, + ArtifactKinds.Js, + doNotRunIfThereWerePreviousFailures +) abstract class NativeBinaryArtifactHandler( - testServices: TestServices -) : BinaryArtifactHandler(testServices, ArtifactKinds.Native) + testServices: TestServices, + doNotRunIfThereWerePreviousFailures: Boolean = false +) : BinaryArtifactHandler( + testServices, + ArtifactKinds.Native, + doNotRunIfThereWerePreviousFailures +) diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/DxCheckerHandler.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/DxCheckerHandler.kt index be430c376d7..29cc5360493 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/DxCheckerHandler.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/DxCheckerHandler.kt @@ -15,7 +15,7 @@ import org.jetbrains.kotlin.test.model.BinaryArtifacts import org.jetbrains.kotlin.test.model.TestModule import org.jetbrains.kotlin.test.services.TestServices -class DxCheckerHandler(testServices: TestServices) : JvmBinaryArtifactHandler(testServices) { +class DxCheckerHandler(testServices: TestServices) : JvmBinaryArtifactHandler(testServices, doNotRunIfThereWerePreviousFailures = true) { override val directivesContainers: List get() = listOf(CodegenTestDirectives) diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/JvmBoxRunner.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/JvmBoxRunner.kt index 9cbf73360da..241a386ba7a 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/JvmBoxRunner.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/JvmBoxRunner.kt @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.utils.addToStdlib.runIf import java.lang.reflect.Method import java.net.URLClassLoader -class JvmBoxRunner(testServices: TestServices) : JvmBinaryArtifactHandler(testServices) { +class JvmBoxRunner(testServices: TestServices) : JvmBinaryArtifactHandler(testServices, doNotRunIfThereWerePreviousFailures = true) { companion object { private val BOX_IN_SEPARATE_PROCESS_PORT = System.getProperty("kotlin.test.box.in.separate.process.port") } diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/classic/handlers/ClassicFrontendAnalysisHandler.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/classic/handlers/ClassicFrontendAnalysisHandler.kt index 3d2be8420f2..7be2d8574b2 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/classic/handlers/ClassicFrontendAnalysisHandler.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/classic/handlers/ClassicFrontendAnalysisHandler.kt @@ -11,7 +11,12 @@ import org.jetbrains.kotlin.test.model.FrontendOutputHandler import org.jetbrains.kotlin.test.services.TestServices abstract class ClassicFrontendAnalysisHandler( - testServices: TestServices -) : FrontendOutputHandler(testServices, FrontendKinds.ClassicFrontend) + testServices: TestServices, + doNotRunIfThereWerePreviousFailures: Boolean = false +) : FrontendOutputHandler( + testServices, + FrontendKinds.ClassicFrontend, + doNotRunIfThereWerePreviousFailures +) diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/handlers/FirAnalysisHandler.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/handlers/FirAnalysisHandler.kt index a8305f22940..f6026ff0ba8 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/handlers/FirAnalysisHandler.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/handlers/FirAnalysisHandler.kt @@ -12,8 +12,9 @@ import org.jetbrains.kotlin.test.services.TestServices import java.io.File abstract class FirAnalysisHandler( - testServices: TestServices -) : FrontendOutputHandler(testServices, FrontendKinds.FIR) { + testServices: TestServices, + doNotRunIfThereWerePreviousFailures: Boolean = false +) : FrontendOutputHandler(testServices, FrontendKinds.FIR, doNotRunIfThereWerePreviousFailures) { protected val File.nameWithoutFirExtension: String get() = nameWithoutExtension.removeSuffix(".fir") }