[ObjCExport][tests] Ignore AA test failures both locally and on CI
To run AA tests normally, use kif.loca gradle property. Merge-request: KT-MR-14129 Merged-by: Alexander Shabalin <alexander.shabalin@ashabalin.me>
This commit is contained in:
committed by
Space Team
parent
15d2799ed4
commit
5525a6829a
@@ -79,11 +79,9 @@ This annotation will
|
||||
- Mark the displayName of the test with 'TODO' (e.g. `[AA] myTest // TODO`)
|
||||
|
||||
Note:
|
||||
- The test will still fail locally (developer setup, not marked as CI).
|
||||
- If the annotation is still present, but the test is successful on CI, then an error is emitted that reminds you about removing the annotation
|
||||
|
||||
The behaviour of the CI can be replicated by passing a Gradle property like
|
||||
- If the annotation is still present, but the test is successful, then an error is emitted that reminds you about removing the annotation
|
||||
- To make the tests execute normally (for more convenient local development), Gradle property `kif.local` can be used:
|
||||
```text
|
||||
./gradlew :native:objcexport-header-generator:check -Pci
|
||||
./gradlew :native:objcexport-header-generator:check -Pkif.local
|
||||
// ^
|
||||
```
|
||||
+4
-3
@@ -6,19 +6,20 @@
|
||||
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
|
||||
|
||||
private val kifLocal = System.getProperty("kif.local")?.toBoolean() ?: throw RuntimeException("Missing 'kif.local' System property")
|
||||
|
||||
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) {
|
||||
if (!kifLocal) {
|
||||
throwable.printStackTrace(System.err)
|
||||
throw AssumptionViolatedException(message, throwable)
|
||||
} else {
|
||||
@@ -33,7 +34,7 @@ internal class TodoAnalysisApiTestExecutionExceptionHandler : TestExecutionExcep
|
||||
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
|
||||
val report: (String) -> Unit = if (!kifLocal) ::error else System.err::println
|
||||
report("Test: ${context.displayName} was marked as 'Todo' but executed successfully")
|
||||
}
|
||||
}
|
||||
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
/*
|
||||
* 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.backend.konan.testUtils
|
||||
|
||||
/**
|
||||
* Indicates if the tests are currently executed on CI like teamcity
|
||||
*/
|
||||
val isCI = System.getProperty("is.ci")?.toBoolean() ?: throw RuntimeException("Missing 'is.ci' System property")
|
||||
+1
-1
@@ -21,7 +21,7 @@ fun Project.objCExportHeaderGeneratorTest(
|
||||
) {
|
||||
useJUnitPlatform()
|
||||
enableJunit5ExtensionsAutodetection()
|
||||
systemProperty("is.ci", kotlinBuildProperties.isTeamcityBuild || project.providers.gradleProperty("ci").isPresent)
|
||||
systemProperty("kif.local", project.providers.gradleProperty("kif.local").isPresent)
|
||||
if (testDisplayNameTag != null) {
|
||||
systemProperty("testDisplayName.tag", testDisplayNameTag)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user