[Test] Handle any Throwable from test instead of AssertionError
This commit is contained in:
+5
-5
@@ -22,7 +22,7 @@ class BlackBoxCodegenSuppressor(testServices: TestServices) : AfterAnalysisCheck
|
||||
override val directives: List<DirectivesContainer>
|
||||
get() = listOf(CodegenTestDirectives)
|
||||
|
||||
override fun suppressIfNeeded(failedAssertions: List<AssertionError>): List<AssertionError> {
|
||||
override fun suppressIfNeeded(failedAssertions: List<Throwable>): List<Throwable> {
|
||||
val moduleStructure = testServices.moduleStructure
|
||||
val targetBackends = moduleStructure.modules.mapNotNull { it.targetBackend }
|
||||
return when (moduleStructure.modules.map { it.frontendKind }.first()) {
|
||||
@@ -36,8 +36,8 @@ class BlackBoxCodegenSuppressor(testServices: TestServices) : AfterAnalysisCheck
|
||||
moduleStructure: TestModuleStructure,
|
||||
directive: ValueDirective<TargetBackend>,
|
||||
targetBackends: List<TargetBackend>,
|
||||
failedAssertions: List<AssertionError>
|
||||
): List<AssertionError> {
|
||||
failedAssertions: List<Throwable>
|
||||
): List<Throwable> {
|
||||
val ignoredBackends = moduleStructure.allDirectives[directive]
|
||||
if (ignoredBackends.isEmpty()) return failedAssertions
|
||||
val matchedBackend = ignoredBackends.intersect(targetBackends)
|
||||
@@ -52,10 +52,10 @@ class BlackBoxCodegenSuppressor(testServices: TestServices) : AfterAnalysisCheck
|
||||
|
||||
|
||||
private fun processAssertions(
|
||||
failedAssertions: List<AssertionError>,
|
||||
failedAssertions: List<Throwable>,
|
||||
directive: ValueDirective<TargetBackend>,
|
||||
additionalMessage: String = ""
|
||||
): List<AssertionError> {
|
||||
): List<Throwable> {
|
||||
return if (failedAssertions.isNotEmpty()) emptyList()
|
||||
else {
|
||||
val message = buildString {
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ class FirIrDumpIdenticalChecker(testServices: TestServices) : AfterAnalysisCheck
|
||||
}
|
||||
}
|
||||
|
||||
override fun check(failedAssertions: List<AssertionError>) {
|
||||
override fun check(failedAssertions: List<Throwable>) {
|
||||
if (failedAssertions.isNotEmpty()) return
|
||||
val testDataFile = testServices.moduleStructure.originalTestDataFiles.first()
|
||||
if (FIR_IDENTICAL in testServices.moduleStructure.allDirectives) {
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ class FirTestDataConsistencyHandler(testServices: TestServices) : AfterAnalysisC
|
||||
override val directives: List<DirectivesContainer>
|
||||
get() = listOf(FirDiagnosticsDirectives)
|
||||
|
||||
override fun check(failedAssertions: List<AssertionError>) {
|
||||
override fun check(failedAssertions: List<Throwable>) {
|
||||
val moduleStructure = testServices.moduleStructure
|
||||
val testData = moduleStructure.originalTestDataFiles.first()
|
||||
if (testData.extension == "kts") return
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ import org.jetbrains.kotlin.test.services.TestServices
|
||||
import org.jetbrains.kotlin.test.services.moduleStructure
|
||||
|
||||
class FirFailingTestSuppressor(testServices: TestServices) : AfterAnalysisChecker(testServices) {
|
||||
override fun suppressIfNeeded(failedAssertions: List<AssertionError>): List<AssertionError> {
|
||||
override fun suppressIfNeeded(failedAssertions: List<Throwable>): List<Throwable> {
|
||||
val testFile = testServices.moduleStructure.originalTestDataFiles.first()
|
||||
val failFile = testFile.parentFile.resolve("${testFile.nameWithoutExtension}.fail")
|
||||
val exceptionFromFir = failedAssertions.firstOrNull { it is ExceptionFromTestError }
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ class FirIdenticalChecker(testServices: TestServices) : AfterAnalysisChecker(tes
|
||||
}
|
||||
}
|
||||
|
||||
override fun check(failedAssertions: List<AssertionError>) {
|
||||
override fun check(failedAssertions: List<Throwable>) {
|
||||
if (failedAssertions.isNotEmpty()) return
|
||||
val testDataFile = testServices.moduleStructure.originalTestDataFiles.first()
|
||||
if (testDataFile.isFirTestData) {
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ object JUnit5Assertions : AssertionsService() {
|
||||
JUnit5PlatformAssertions.assertFalse(value, message?.invoke())
|
||||
}
|
||||
|
||||
override fun assertAll(exceptions: List<AssertionError>) {
|
||||
override fun assertAll(exceptions: List<Throwable>) {
|
||||
exceptions.singleOrNull()?.let { throw it }
|
||||
JUnit5PlatformAssertions.assertAll(exceptions.map { Executable { throw it } })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user