From 5525a6829a9f2a1478c0b81cf5f7b363d986b933 Mon Sep 17 00:00:00 2001 From: Alexander Shabalin Date: Fri, 2 Feb 2024 13:43:30 +0000 Subject: [PATCH] [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 --- native/objcexport-header-generator/ReadMe.md | 10 ++++------ .../TodoAnalysisApiTestExecutionExceptionHandler.kt | 7 ++++--- .../jetbrains/kotlin/backend/konan/testUtils/isCI.kt | 11 ----------- .../src/main/kotlin/objcExportHeaderGeneratorTest.kt | 2 +- 4 files changed, 9 insertions(+), 21 deletions(-) delete mode 100644 native/objcexport-header-generator/test/org/jetbrains/kotlin/backend/konan/testUtils/isCI.kt diff --git a/native/objcexport-header-generator/ReadMe.md b/native/objcexport-header-generator/ReadMe.md index ef787ea8c10..05e4d25d17c 100644 --- a/native/objcexport-header-generator/ReadMe.md +++ b/native/objcexport-header-generator/ReadMe.md @@ -78,12 +78,10 @@ This annotation will - Ignore test the test failure for the AA based implementation on the CI - 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 +Note: +- 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 // ^ ``` \ No newline at end of file diff --git a/native/objcexport-header-generator/impl/analysis-api/test/org/jetbrains/kotlin/objcexport/testUtils/TodoAnalysisApiTestExecutionExceptionHandler.kt b/native/objcexport-header-generator/impl/analysis-api/test/org/jetbrains/kotlin/objcexport/testUtils/TodoAnalysisApiTestExecutionExceptionHandler.kt index ffc12dea8fc..d18b96cec39 100644 --- a/native/objcexport-header-generator/impl/analysis-api/test/org/jetbrains/kotlin/objcexport/testUtils/TodoAnalysisApiTestExecutionExceptionHandler.kt +++ b/native/objcexport-header-generator/impl/analysis-api/test/org/jetbrains/kotlin/objcexport/testUtils/TodoAnalysisApiTestExecutionExceptionHandler.kt @@ -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") } } diff --git a/native/objcexport-header-generator/test/org/jetbrains/kotlin/backend/konan/testUtils/isCI.kt b/native/objcexport-header-generator/test/org/jetbrains/kotlin/backend/konan/testUtils/isCI.kt deleted file mode 100644 index 97438cbeaeb..00000000000 --- a/native/objcexport-header-generator/test/org/jetbrains/kotlin/backend/konan/testUtils/isCI.kt +++ /dev/null @@ -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") \ No newline at end of file diff --git a/repo/gradle-build-conventions/buildsrc-compat/src/main/kotlin/objcExportHeaderGeneratorTest.kt b/repo/gradle-build-conventions/buildsrc-compat/src/main/kotlin/objcExportHeaderGeneratorTest.kt index b88a644c4e3..de8ff0b9dbc 100644 --- a/repo/gradle-build-conventions/buildsrc-compat/src/main/kotlin/objcExportHeaderGeneratorTest.kt +++ b/repo/gradle-build-conventions/buildsrc-compat/src/main/kotlin/objcExportHeaderGeneratorTest.kt @@ -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) }