[Test] Add ability to disable specific handler if there was an error from previous one
This commit is contained in:
@@ -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<AnalysisHandler<*>> = 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<AnalysisHandler<*>> = 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<AnalysisHandler<*>> = 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)
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------
|
||||
|
||||
+13
-7
@@ -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<A : ResultingArtifact<A>>(val testServices: TestServices) {
|
||||
abstract class AnalysisHandler<A : ResultingArtifact<A>>(
|
||||
val testServices: TestServices,
|
||||
val doNotRunIfThereWerePreviousFailures: Boolean
|
||||
) {
|
||||
protected val assertions: Assertions
|
||||
get() = testServices.assertions
|
||||
|
||||
@@ -30,15 +33,18 @@ abstract class AnalysisHandler<A : ResultingArtifact<A>>(val testServices: TestS
|
||||
|
||||
abstract class FrontendOutputHandler<R : ResultingArtifact.FrontendOutput<R>>(
|
||||
testServices: TestServices,
|
||||
override val artifactKind: FrontendKind<R>
|
||||
) : AnalysisHandler<R>(testServices)
|
||||
override val artifactKind: FrontendKind<R>,
|
||||
doNotRunIfThereWerePreviousFailures: Boolean
|
||||
) : AnalysisHandler<R>(testServices, doNotRunIfThereWerePreviousFailures)
|
||||
|
||||
abstract class BackendInputHandler<I : ResultingArtifact.BackendInput<I>>(
|
||||
testServices: TestServices,
|
||||
override val artifactKind: BackendKind<I>
|
||||
) : AnalysisHandler<I>(testServices)
|
||||
override val artifactKind: BackendKind<I>,
|
||||
doNotRunIfThereWerePreviousFailures: Boolean
|
||||
) : AnalysisHandler<I>(testServices, doNotRunIfThereWerePreviousFailures)
|
||||
|
||||
abstract class BinaryArtifactHandler<A : ResultingArtifact.Binary<A>>(
|
||||
testServices: TestServices,
|
||||
override val artifactKind: BinaryKind<A>
|
||||
) : AnalysisHandler<A>(testServices)
|
||||
override val artifactKind: BinaryKind<A>,
|
||||
doNotRunIfThereWerePreviousFailures: Boolean
|
||||
) : AnalysisHandler<A>(testServices, doNotRunIfThereWerePreviousFailures)
|
||||
|
||||
+4
-1
@@ -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<IrBackendInput>(testServices, BackendKinds.IrBackend)
|
||||
abstract class AbstractIrHandler(
|
||||
testServices: TestServices,
|
||||
doNotRunIfThereWerePreviousFailures: Boolean = false
|
||||
) : BackendInputHandler<IrBackendInput>(testServices, BackendKinds.IrBackend, doNotRunIfThereWerePreviousFailures)
|
||||
|
||||
+21
-6
@@ -11,13 +11,28 @@ import org.jetbrains.kotlin.test.model.BinaryArtifacts
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
|
||||
abstract class JvmBinaryArtifactHandler(
|
||||
testServices: TestServices
|
||||
) : BinaryArtifactHandler<BinaryArtifacts.Jvm>(testServices, ArtifactKinds.Jvm)
|
||||
testServices: TestServices,
|
||||
doNotRunIfThereWerePreviousFailures: Boolean = false
|
||||
) : BinaryArtifactHandler<BinaryArtifacts.Jvm>(
|
||||
testServices,
|
||||
ArtifactKinds.Jvm,
|
||||
doNotRunIfThereWerePreviousFailures
|
||||
)
|
||||
|
||||
abstract class JsBinaryArtifactHandler(
|
||||
testServices: TestServices
|
||||
) : BinaryArtifactHandler<BinaryArtifacts.Js>(testServices, ArtifactKinds.Js)
|
||||
testServices: TestServices,
|
||||
doNotRunIfThereWerePreviousFailures: Boolean = false
|
||||
) : BinaryArtifactHandler<BinaryArtifacts.Js>(
|
||||
testServices,
|
||||
ArtifactKinds.Js,
|
||||
doNotRunIfThereWerePreviousFailures
|
||||
)
|
||||
|
||||
abstract class NativeBinaryArtifactHandler(
|
||||
testServices: TestServices
|
||||
) : BinaryArtifactHandler<BinaryArtifacts.Native>(testServices, ArtifactKinds.Native)
|
||||
testServices: TestServices,
|
||||
doNotRunIfThereWerePreviousFailures: Boolean = false
|
||||
) : BinaryArtifactHandler<BinaryArtifacts.Native>(
|
||||
testServices,
|
||||
ArtifactKinds.Native,
|
||||
doNotRunIfThereWerePreviousFailures
|
||||
)
|
||||
|
||||
+1
-1
@@ -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<DirectivesContainer>
|
||||
get() = listOf(CodegenTestDirectives)
|
||||
|
||||
|
||||
+1
-1
@@ -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")
|
||||
}
|
||||
|
||||
+7
-2
@@ -11,7 +11,12 @@ import org.jetbrains.kotlin.test.model.FrontendOutputHandler
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
|
||||
abstract class ClassicFrontendAnalysisHandler(
|
||||
testServices: TestServices
|
||||
) : FrontendOutputHandler<ClassicFrontendOutputArtifact>(testServices, FrontendKinds.ClassicFrontend)
|
||||
testServices: TestServices,
|
||||
doNotRunIfThereWerePreviousFailures: Boolean = false
|
||||
) : FrontendOutputHandler<ClassicFrontendOutputArtifact>(
|
||||
testServices,
|
||||
FrontendKinds.ClassicFrontend,
|
||||
doNotRunIfThereWerePreviousFailures
|
||||
)
|
||||
|
||||
|
||||
|
||||
+3
-2
@@ -12,8 +12,9 @@ import org.jetbrains.kotlin.test.services.TestServices
|
||||
import java.io.File
|
||||
|
||||
abstract class FirAnalysisHandler(
|
||||
testServices: TestServices
|
||||
) : FrontendOutputHandler<FirOutputArtifact>(testServices, FrontendKinds.FIR) {
|
||||
testServices: TestServices,
|
||||
doNotRunIfThereWerePreviousFailures: Boolean = false
|
||||
) : FrontendOutputHandler<FirOutputArtifact>(testServices, FrontendKinds.FIR, doNotRunIfThereWerePreviousFailures) {
|
||||
protected val File.nameWithoutFirExtension: String
|
||||
get() = nameWithoutExtension.removeSuffix(".fir")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user