From a81c44301d61e418e72a892ce82c5cff356fe4d7 Mon Sep 17 00:00:00 2001 From: Dmitriy Dolovov Date: Fri, 3 Dec 2021 17:24:54 +0300 Subject: [PATCH] [Native][tests] Separate Gradle tasks for different types of tests --- native/native.tests/build.gradle.kts | 34 +++++++++++++++---- .../tests/GenerateNativeBlackboxTests.kt | 8 +++-- .../blackboxtest/NativeStdlibBlackBoxTest.kt | 2 ++ .../TestInfra_CompressedNamesTest.kt | 2 ++ .../TestInfra_GlobsExpansionTest.kt | 2 ++ .../TestInfra_NamedEntitiesTest.kt | 2 ++ .../blackboxtest/TestInfra_TestListingTest.kt | 2 ++ 7 files changed, 43 insertions(+), 9 deletions(-) diff --git a/native/native.tests/build.gradle.kts b/native/native.tests/build.gradle.kts index 5e268537351..6b15d035786 100644 --- a/native/native.tests/build.gradle.kts +++ b/native/native.tests/build.gradle.kts @@ -59,9 +59,9 @@ enum class TestProperty(shortName: String) { } } -if (kotlinBuildProperties.isKotlinNativeEnabled) { - projectTest(taskName = "test", jUnitMode = JUnitMode.JUnit5) { - dependsOn(":kotlin-native:dist" /*, ":kotlin-native:distPlatformLibs"*/) +fun Test.setUpBlackBoxTest(tag: String) { + if (kotlinBuildProperties.isKotlinNativeEnabled) { + dependsOn(":kotlin-native:dist") workingDir = rootDir maxHeapSize = "6G" // Extra heap space for Kotlin/Native compiler. @@ -86,10 +86,10 @@ if (kotlinBuildProperties.isKotlinNativeEnabled) { TestProperty.USE_CACHE.setUpFromGradleProperty(this) TestProperty.EXECUTION_TIMEOUT.setUpFromGradleProperty(this) - useJUnitPlatform() - } -} else { - getOrCreateTask(taskName = "test") { + useJUnitPlatform { + includeTags(tag) + } + } else { doFirst { throw GradleException( """ @@ -102,6 +102,26 @@ if (kotlinBuildProperties.isKotlinNativeEnabled) { } } +val infrastructureTest by projectTest(taskName = "infrastructureTest", jUnitMode = JUnitMode.JUnit5) { + useJUnitPlatform { + includeTags("infrastructure") + } +} + +val dailyTest by projectTest(taskName = "dailyTest", jUnitMode = JUnitMode.JUnit5) { + setUpBlackBoxTest("daily") +} + +// Just an alias for daily test task. +val test: Task by tasks.getting { + dependsOn(dailyTest) +} + +projectTest(taskName = "fullTest", jUnitMode = JUnitMode.JUnit5) { + dependsOn(dailyTest, infrastructureTest) + // TODO: migrate and attach K/N blackbox tests from kotlin-native/backend.native/tests +} + val generateTests by generator("org.jetbrains.kotlin.generators.tests.GenerateNativeBlackboxTestsKt") { javaLauncher.set(project.getToolchainLauncherFor(JdkMajorVersion.JDK_11)) dependsOn(":compiler:generateTestData") diff --git a/native/native.tests/tests/org/jetbrains/kotlin/generators/tests/GenerateNativeBlackboxTests.kt b/native/native.tests/tests/org/jetbrains/kotlin/generators/tests/GenerateNativeBlackboxTests.kt index 396476a7440..7a859988d55 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/generators/tests/GenerateNativeBlackboxTests.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/generators/tests/GenerateNativeBlackboxTests.kt @@ -11,6 +11,7 @@ import org.jetbrains.kotlin.konan.blackboxtest.AbstractNativeBlackBoxTest import org.jetbrains.kotlin.konan.blackboxtest.support.group.UseExtTestCaseGroupProvider import org.jetbrains.kotlin.konan.blackboxtest.support.group.UseStandardTestCaseGroupProvider import org.jetbrains.kotlin.test.TargetBackend +import org.junit.jupiter.api.Tag fun main() { System.setProperty("java.awt.headless", "true") @@ -20,7 +21,7 @@ fun main() { testGroup("native/native.tests/tests-gen", "compiler/testData") { testClass( suiteTestClassName = "NativeExtBlackBoxTestGenerated", - annotations = listOf(annotation(UseExtTestCaseGroupProvider::class.java)) + annotations = listOf(daily(), provider()) ) { model("codegen/box", targetBackend = TargetBackend.NATIVE) model("codegen/boxInline", targetBackend = TargetBackend.NATIVE) @@ -30,7 +31,7 @@ fun main() { // Samples (how to utilize the abilities of new test infrastructure). testGroup("native/native.tests/tests-gen", "native/native.tests/testData") { testClass( - annotations = listOf(annotation(UseStandardTestCaseGroupProvider::class.java)) + annotations = listOf(daily(), provider()) ) { model("samples") model("samples2") @@ -38,3 +39,6 @@ fun main() { } } } + +private inline fun provider() = annotation(T::class.java) +private fun daily() = annotation(Tag::class.java, "daily") diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/NativeStdlibBlackBoxTest.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/NativeStdlibBlackBoxTest.kt index 1d166367a9a..416d24faadc 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/NativeStdlibBlackBoxTest.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/NativeStdlibBlackBoxTest.kt @@ -10,8 +10,10 @@ package org.jetbrains.kotlin.konan.blackboxtest import org.jetbrains.kotlin.konan.blackboxtest.support.TestCaseId import org.jetbrains.kotlin.konan.blackboxtest.support.group.PredefinedTestCase as TC import org.jetbrains.kotlin.konan.blackboxtest.support.group.PredefinedTestCases +import org.junit.jupiter.api.Tag import org.junit.jupiter.api.TestFactory +@Tag("daily") @PredefinedTestCases( TC( name = "nativeStdlib", diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/TestInfra_CompressedNamesTest.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/TestInfra_CompressedNamesTest.kt index d6edf306843..c78a0e3d209 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/TestInfra_CompressedNamesTest.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/TestInfra_CompressedNamesTest.kt @@ -14,10 +14,12 @@ import org.jetbrains.kotlin.konan.target.Family import org.jetbrains.kotlin.konan.target.KonanTarget import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertTrue +import org.junit.jupiter.api.Tag import org.junit.jupiter.api.Test import kotlin.coroutines.Continuation @Suppress("ClassName") +@Tag("infrastructure") class TestInfra_CompressedNamesTest { @Test fun targetNameCompression() { diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/TestInfra_GlobsExpansionTest.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/TestInfra_GlobsExpansionTest.kt index 5b3ce28f89c..0dfbeb95480 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/TestInfra_GlobsExpansionTest.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/TestInfra_GlobsExpansionTest.kt @@ -10,12 +10,14 @@ import org.jetbrains.kotlin.konan.blackboxtest.support.util.sanitizedName import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Tag import org.junit.jupiter.api.Test import org.junit.jupiter.api.fail import java.io.File import kotlin.io.path.createTempDirectory @Suppress("ClassName") +@Tag("infrastructure") class TestInfra_GlobsExpansionTest { private lateinit var testDir: File diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/TestInfra_NamedEntitiesTest.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/TestInfra_NamedEntitiesTest.kt index 68ea7e550ea..b737da4fe81 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/TestInfra_NamedEntitiesTest.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/TestInfra_NamedEntitiesTest.kt @@ -8,9 +8,11 @@ package org.jetbrains.kotlin.konan.blackboxtest import org.jetbrains.kotlin.konan.blackboxtest.support.PackageName import org.jetbrains.kotlin.konan.blackboxtest.support.TestName import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Tag import org.junit.jupiter.api.Test @Suppress("ClassName") +@Tag("infrastructure") class TestInfra_NamedEntitiesTest { @Test fun parsePackageName() { diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/TestInfra_TestListingTest.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/TestInfra_TestListingTest.kt index de589bcd1ef..d5f39c6c544 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/TestInfra_TestListingTest.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/TestInfra_TestListingTest.kt @@ -8,9 +8,11 @@ package org.jetbrains.kotlin.konan.blackboxtest import org.jetbrains.kotlin.konan.blackboxtest.support.TestName import org.jetbrains.kotlin.konan.blackboxtest.support.util.parseGTestListing import org.junit.jupiter.api.Assertions.* +import org.junit.jupiter.api.Tag import org.junit.jupiter.api.Test @Suppress("ClassName") +@Tag("infrastructure") class TestInfra_TestListingTest { @Test fun successfullyParsed() = assertEquals(