[ObjCExport] Implement 'TodoAnalysisApi' annotation and run AA based tests as part of ':native:objcexport-header-generator:check'
^KT-65281 Fixed ^KT-65108 Fixed
This commit is contained in:
committed by
Space Team
parent
55adeba011
commit
0db8931026
@@ -27,7 +27,4 @@ sourceSets {
|
||||
|
||||
testsJar()
|
||||
|
||||
nativeTest("test", tag = null, requirePlatformLibs = true) {
|
||||
useJUnitPlatform()
|
||||
enableJunit5ExtensionsAutodetection()
|
||||
}
|
||||
objCExportHeaderGeneratorTest("test")
|
||||
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2010-2024 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.objcexport.testUtils
|
||||
|
||||
import org.jetbrains.kotlin.backend.konan.testUtils.TodoAnalysisApi
|
||||
import org.jetbrains.kotlin.backend.konan.testUtils.isCI
|
||||
import org.junit.AssumptionViolatedException
|
||||
import org.junit.jupiter.api.extension.AfterEachCallback
|
||||
import org.junit.jupiter.api.extension.ExtensionContext
|
||||
import org.junit.jupiter.api.extension.TestExecutionExceptionHandler
|
||||
import kotlin.jvm.optionals.getOrNull
|
||||
|
||||
internal class TodoAnalysisApiTestExecutionExceptionHandler : TestExecutionExceptionHandler, AfterEachCallback {
|
||||
override fun handleTestExecutionException(context: ExtensionContext, throwable: Throwable) {
|
||||
val element = context.element.getOrNull() ?: return
|
||||
if (element.isAnnotationPresent(TodoAnalysisApi::class.java)) {
|
||||
val message = "Test is marked as 'Todo' for Analysis Api"
|
||||
if (isCI) {
|
||||
throwable.printStackTrace(System.err)
|
||||
throw AssumptionViolatedException(message, throwable)
|
||||
} else {
|
||||
context.publishReportEntry(message)
|
||||
System.err.println(message)
|
||||
}
|
||||
}
|
||||
|
||||
throw throwable
|
||||
}
|
||||
|
||||
override fun afterEach(context: ExtensionContext) {
|
||||
val element = context.element.getOrNull() ?: return
|
||||
if (element.isAnnotationPresent(TodoAnalysisApi::class.java) && context.executionException.getOrNull() == null) {
|
||||
val report: (String) -> Unit = if (isCI) ::error else System.err::println
|
||||
report("Test: ${context.displayName} was marked as 'Todo' but executed successfully")
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -4,4 +4,5 @@
|
||||
#
|
||||
org.jetbrains.kotlin.objcexport.testUtils.AnalysisApiHeaderGeneratorExtension
|
||||
org.jetbrains.kotlin.objcexport.testUtils.InlineSourceCodeAnalysisExtension
|
||||
org.jetbrains.kotlin.objcexport.testUtils.AnalysisApiBaseDeclarationsGeneratorExtension
|
||||
org.jetbrains.kotlin.objcexport.testUtils.AnalysisApiBaseDeclarationsGeneratorExtension
|
||||
org.jetbrains.kotlin.objcexport.testUtils.TodoAnalysisApiTestExecutionExceptionHandler
|
||||
Reference in New Issue
Block a user