[Native][tests] Re-organize Gradle tasks and test suite classes

This commit is contained in:
Dmitriy Dolovov
2021-12-09 02:41:06 +03:00
parent 835de3083a
commit 72bb38dc68
8 changed files with 21 additions and 30 deletions
+8 -13
View File
@@ -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<Test> { group = "verification" }
val generateTests by generator("org.jetbrains.kotlin.generators.tests.GenerateNativeBlackboxTestsKt") {
javaLauncher.set(project.getToolchainLauncherFor(JdkMajorVersion.JDK_11))
@@ -20,8 +20,8 @@ fun main() {
// External box tests.
testGroup("native/native.tests/tests-gen", "compiler/testData") {
testClass<AbstractNativeBlackBoxTest>(
suiteTestClassName = "NativeExtBlackBoxTestGenerated",
annotations = listOf(daily(), provider<UseExtTestCaseGroupProvider>())
suiteTestClassName = "ExternalTestGenerated",
annotations = listOf(external(), provider<UseExtTestCaseGroupProvider>())
) {
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<AbstractNativeBlackBoxTest>(
suiteTestClassName = "NativeInfraBlackBoxTestGenerated",
suiteTestClassName = "InfrastructureTestGenerated",
annotations = listOf(infrastructure(), provider<UseStandardTestCaseGroupProvider>())
) {
model("samples")
@@ -42,5 +42,6 @@ fun main() {
}
private inline fun <reified T : Annotation> 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")
@@ -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> = KonanTarget.predefinedTargets.values.toSet()
@@ -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
@@ -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(
@@ -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("")
@@ -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(
@@ -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"))