From 72bb38dc68a1915411e56efb7f07057eb7000d77 Mon Sep 17 00:00:00 2001 From: Dmitriy Dolovov Date: Thu, 9 Dec 2021 02:41:06 +0300 Subject: [PATCH] [Native][tests] Re-organize Gradle tasks and test suite classes --- native/native.tests/build.gradle.kts | 21 +++++++------------ .../tests/GenerateNativeBlackboxTests.kt | 9 ++++---- ...t => InfrastructureCompressedNamesTest.kt} | 3 +-- ...kt => InfrastructureGlobsExpansionTest.kt} | 5 ++--- ....kt => InfrastructureNamedEntitiesTest.kt} | 3 +-- ...t.kt => InfrastructureOutputFilterTest.kt} | 3 +-- ...st.kt => InfrastructureTestListingTest.kt} | 3 +-- ...iveStdlibBlackBoxTest.kt => StdlibTest.kt} | 4 ++-- 8 files changed, 21 insertions(+), 30 deletions(-) rename native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/{TestInfra_CompressedNamesTest.kt => InfrastructureCompressedNamesTest.kt} (98%) rename native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/{TestInfra_GlobsExpansionTest.kt => InfrastructureGlobsExpansionTest.kt} (96%) rename native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/{TestInfra_NamedEntitiesTest.kt => InfrastructureNamedEntitiesTest.kt} (97%) rename native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/{TestInfra_OutputFilterTest.kt => InfrastructureOutputFilterTest.kt} (98%) rename native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/{TestInfra_TestListingTest.kt => InfrastructureTestListingTest.kt} (98%) rename native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/{NativeStdlibBlackBoxTest.kt => StdlibTest.kt} (97%) diff --git a/native/native.tests/build.gradle.kts b/native/native.tests/build.gradle.kts index cb18ac3c377..14b034a6bdb 100644 --- a/native/native.tests/build.gradle.kts +++ b/native/native.tests/build.gradle.kts @@ -104,23 +104,18 @@ fun Test.setUpBlackBoxTest(tag: String) { } } -val infrastructureTest by projectTest(taskName = "infrastructureTest", jUnitMode = JUnitMode.JUnit5) { - setUpBlackBoxTest("infrastructure") -} +// Tasks that run different sorts of tests. Most frequent use case: running specific tests from the IDE. +val infrastructureTest = projectTest("infrastructureTest", jUnitMode = JUnitMode.JUnit5) { setUpBlackBoxTest("infrastructure") } +val externalTest = projectTest("externalTest", jUnitMode = JUnitMode.JUnit5) { setUpBlackBoxTest("external") } -val dailyTest by projectTest(taskName = "dailyTest", jUnitMode = JUnitMode.JUnit5) { - setUpBlackBoxTest("daily") -} +// Tasks that do not run tests directly, but group other test tasks. Most frequent use case: running groups of tests on CI server. +val dailyTest by tasks.registering(Test::class) { dependsOn(externalTest) } +val fullTest by tasks.registering(Test::class) { dependsOn(dailyTest, infrastructureTest) } // Just an alias for daily test task. -val test: Task by tasks.getting { - dependsOn(dailyTest) -} +val test by tasks.getting(Test::class) { 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 -} +tasks.withType { group = "verification" } val generateTests by generator("org.jetbrains.kotlin.generators.tests.GenerateNativeBlackboxTestsKt") { javaLauncher.set(project.getToolchainLauncherFor(JdkMajorVersion.JDK_11)) 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 813879ec662..f80de6aef51 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 @@ -20,8 +20,8 @@ fun main() { // External box tests. testGroup("native/native.tests/tests-gen", "compiler/testData") { testClass( - suiteTestClassName = "NativeExtBlackBoxTestGenerated", - annotations = listOf(daily(), provider()) + suiteTestClassName = "ExternalTestGenerated", + annotations = listOf(external(), provider()) ) { model("codegen/box", targetBackend = TargetBackend.NATIVE) model("codegen/boxInline", targetBackend = TargetBackend.NATIVE) @@ -31,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( - suiteTestClassName = "NativeInfraBlackBoxTestGenerated", + suiteTestClassName = "InfrastructureTestGenerated", annotations = listOf(infrastructure(), provider()) ) { model("samples") @@ -42,5 +42,6 @@ fun main() { } private inline fun provider() = annotation(T::class.java) -private fun daily() = annotation(Tag::class.java, "daily") + +private fun external() = annotation(Tag::class.java, "external") private fun infrastructure() = annotation(Tag::class.java, "infrastructure") 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/InfrastructureCompressedNamesTest.kt similarity index 98% rename from native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/TestInfra_CompressedNamesTest.kt rename to native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/InfrastructureCompressedNamesTest.kt index c78a0e3d209..1dca9c8752e 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/TestInfra_CompressedNamesTest.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/InfrastructureCompressedNamesTest.kt @@ -18,9 +18,8 @@ import org.junit.jupiter.api.Tag import org.junit.jupiter.api.Test import kotlin.coroutines.Continuation -@Suppress("ClassName") @Tag("infrastructure") -class TestInfra_CompressedNamesTest { +class InfrastructureCompressedNamesTest { @Test fun targetNameCompression() { val knownTargets: Set = KonanTarget.predefinedTargets.values.toSet() 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/InfrastructureGlobsExpansionTest.kt similarity index 96% rename from native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/TestInfra_GlobsExpansionTest.kt rename to native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/InfrastructureGlobsExpansionTest.kt index 0dfbeb95480..7817e5b1886 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/TestInfra_GlobsExpansionTest.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/InfrastructureGlobsExpansionTest.kt @@ -16,14 +16,13 @@ import org.junit.jupiter.api.fail import java.io.File import kotlin.io.path.createTempDirectory -@Suppress("ClassName") @Tag("infrastructure") -class TestInfra_GlobsExpansionTest { +class InfrastructureGlobsExpansionTest { private lateinit var testDir: File @BeforeEach fun setUp() { - testDir = createTempDirectory(TestInfra_GlobsExpansionTest::class.java.sanitizedName).toFile() + testDir = createTempDirectory(InfrastructureGlobsExpansionTest::class.java.sanitizedName).toFile() } @Test 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/InfrastructureNamedEntitiesTest.kt similarity index 97% rename from native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/TestInfra_NamedEntitiesTest.kt rename to native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/InfrastructureNamedEntitiesTest.kt index b737da4fe81..b57c6685dec 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/TestInfra_NamedEntitiesTest.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/InfrastructureNamedEntitiesTest.kt @@ -11,9 +11,8 @@ 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 { +class InfrastructureNamedEntitiesTest { @Test fun parsePackageName() { listOf( diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/TestInfra_OutputFilterTest.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/InfrastructureOutputFilterTest.kt similarity index 98% rename from native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/TestInfra_OutputFilterTest.kt rename to native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/InfrastructureOutputFilterTest.kt index eccc5cc6442..152ee1e3a80 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/TestInfra_OutputFilterTest.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/InfrastructureOutputFilterTest.kt @@ -12,9 +12,8 @@ import org.junit.jupiter.api.Assertions.* import org.junit.jupiter.api.Tag import org.junit.jupiter.api.Test -@Suppress("ClassName") @Tag("infrastructure") -class TestInfra_OutputFilterTest { +class InfrastructureOutputFilterTest { @Test fun noFiltering() { val randomTestOutput = List(100) { (Char.MIN_VALUE..Char.MAX_VALUE).random() }.joinToString("") 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/InfrastructureTestListingTest.kt similarity index 98% rename from native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/TestInfra_TestListingTest.kt rename to native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/InfrastructureTestListingTest.kt index ca695ccf55c..0ce2f81bf72 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/TestInfra_TestListingTest.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/InfrastructureTestListingTest.kt @@ -11,9 +11,8 @@ 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 { +class InfrastructureTestListingTest { @Test fun successfullyParsed() = assertEquals( listOf( diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/NativeStdlibBlackBoxTest.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/StdlibTest.kt similarity index 97% rename from native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/NativeStdlibBlackBoxTest.kt rename to native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/StdlibTest.kt index 022eabba8e0..2c01b12ca00 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/NativeStdlibBlackBoxTest.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/StdlibTest.kt @@ -15,7 +15,7 @@ import org.jetbrains.kotlin.konan.blackboxtest.support.group.PredefinedTestCases import org.junit.jupiter.api.Tag import org.junit.jupiter.api.TestFactory -@Tag("daily") +@Tag("external") @PredefinedTestCases( TC( name = "nativeStdlib", @@ -54,7 +54,7 @@ import org.junit.jupiter.api.TestFactory sourceLocations = ["libraries/kotlin.test/common/src/test/kotlin/**.kt"] ) ) -class NativeStdlibBlackBoxTest : AbstractNativeBlackBoxTest() { +class StdlibTest : AbstractNativeBlackBoxTest() { @TestFactory fun kotlinTest() = dynamicTestCase(TestCaseId.Named("kotlinTest"))