[Native][tests] Separate Gradle tasks for different types of tests

This commit is contained in:
Dmitriy Dolovov
2021-12-03 17:24:54 +03:00
parent 3756634b84
commit a81c44301d
7 changed files with 43 additions and 9 deletions
+27 -7
View File
@@ -59,9 +59,9 @@ enum class TestProperty(shortName: String) {
} }
} }
if (kotlinBuildProperties.isKotlinNativeEnabled) { fun Test.setUpBlackBoxTest(tag: String) {
projectTest(taskName = "test", jUnitMode = JUnitMode.JUnit5) { if (kotlinBuildProperties.isKotlinNativeEnabled) {
dependsOn(":kotlin-native:dist" /*, ":kotlin-native:distPlatformLibs"*/) dependsOn(":kotlin-native:dist")
workingDir = rootDir workingDir = rootDir
maxHeapSize = "6G" // Extra heap space for Kotlin/Native compiler. maxHeapSize = "6G" // Extra heap space for Kotlin/Native compiler.
@@ -86,10 +86,10 @@ if (kotlinBuildProperties.isKotlinNativeEnabled) {
TestProperty.USE_CACHE.setUpFromGradleProperty(this) TestProperty.USE_CACHE.setUpFromGradleProperty(this)
TestProperty.EXECUTION_TIMEOUT.setUpFromGradleProperty(this) TestProperty.EXECUTION_TIMEOUT.setUpFromGradleProperty(this)
useJUnitPlatform() useJUnitPlatform {
} includeTags(tag)
} else { }
getOrCreateTask<Test>(taskName = "test") { } else {
doFirst { doFirst {
throw GradleException( 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") { val generateTests by generator("org.jetbrains.kotlin.generators.tests.GenerateNativeBlackboxTestsKt") {
javaLauncher.set(project.getToolchainLauncherFor(JdkMajorVersion.JDK_11)) javaLauncher.set(project.getToolchainLauncherFor(JdkMajorVersion.JDK_11))
dependsOn(":compiler:generateTestData") dependsOn(":compiler:generateTestData")
@@ -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.UseExtTestCaseGroupProvider
import org.jetbrains.kotlin.konan.blackboxtest.support.group.UseStandardTestCaseGroupProvider import org.jetbrains.kotlin.konan.blackboxtest.support.group.UseStandardTestCaseGroupProvider
import org.jetbrains.kotlin.test.TargetBackend import org.jetbrains.kotlin.test.TargetBackend
import org.junit.jupiter.api.Tag
fun main() { fun main() {
System.setProperty("java.awt.headless", "true") System.setProperty("java.awt.headless", "true")
@@ -20,7 +21,7 @@ fun main() {
testGroup("native/native.tests/tests-gen", "compiler/testData") { testGroup("native/native.tests/tests-gen", "compiler/testData") {
testClass<AbstractNativeBlackBoxTest>( testClass<AbstractNativeBlackBoxTest>(
suiteTestClassName = "NativeExtBlackBoxTestGenerated", suiteTestClassName = "NativeExtBlackBoxTestGenerated",
annotations = listOf(annotation(UseExtTestCaseGroupProvider::class.java)) annotations = listOf(daily(), provider<UseExtTestCaseGroupProvider>())
) { ) {
model("codegen/box", targetBackend = TargetBackend.NATIVE) model("codegen/box", targetBackend = TargetBackend.NATIVE)
model("codegen/boxInline", 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). // Samples (how to utilize the abilities of new test infrastructure).
testGroup("native/native.tests/tests-gen", "native/native.tests/testData") { testGroup("native/native.tests/tests-gen", "native/native.tests/testData") {
testClass<AbstractNativeBlackBoxTest>( testClass<AbstractNativeBlackBoxTest>(
annotations = listOf(annotation(UseStandardTestCaseGroupProvider::class.java)) annotations = listOf(daily(), provider<UseStandardTestCaseGroupProvider>())
) { ) {
model("samples") model("samples")
model("samples2") model("samples2")
@@ -38,3 +39,6 @@ fun main() {
} }
} }
} }
private inline fun <reified T : Annotation> provider() = annotation(T::class.java)
private fun daily() = annotation(Tag::class.java, "daily")
@@ -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.TestCaseId
import org.jetbrains.kotlin.konan.blackboxtest.support.group.PredefinedTestCase as TC import org.jetbrains.kotlin.konan.blackboxtest.support.group.PredefinedTestCase as TC
import org.jetbrains.kotlin.konan.blackboxtest.support.group.PredefinedTestCases import org.jetbrains.kotlin.konan.blackboxtest.support.group.PredefinedTestCases
import org.junit.jupiter.api.Tag
import org.junit.jupiter.api.TestFactory import org.junit.jupiter.api.TestFactory
@Tag("daily")
@PredefinedTestCases( @PredefinedTestCases(
TC( TC(
name = "nativeStdlib", name = "nativeStdlib",
@@ -14,10 +14,12 @@ import org.jetbrains.kotlin.konan.target.Family
import org.jetbrains.kotlin.konan.target.KonanTarget import org.jetbrains.kotlin.konan.target.KonanTarget
import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Tag
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import kotlin.coroutines.Continuation import kotlin.coroutines.Continuation
@Suppress("ClassName") @Suppress("ClassName")
@Tag("infrastructure")
class TestInfra_CompressedNamesTest { class TestInfra_CompressedNamesTest {
@Test @Test
fun targetNameCompression() { fun targetNameCompression() {
@@ -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.assertEquals
import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Tag
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import org.junit.jupiter.api.fail import org.junit.jupiter.api.fail
import java.io.File import java.io.File
import kotlin.io.path.createTempDirectory import kotlin.io.path.createTempDirectory
@Suppress("ClassName") @Suppress("ClassName")
@Tag("infrastructure")
class TestInfra_GlobsExpansionTest { class TestInfra_GlobsExpansionTest {
private lateinit var testDir: File private lateinit var testDir: File
@@ -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.PackageName
import org.jetbrains.kotlin.konan.blackboxtest.support.TestName import org.jetbrains.kotlin.konan.blackboxtest.support.TestName
import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Tag
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
@Suppress("ClassName") @Suppress("ClassName")
@Tag("infrastructure")
class TestInfra_NamedEntitiesTest { class TestInfra_NamedEntitiesTest {
@Test @Test
fun parsePackageName() { fun parsePackageName() {
@@ -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.TestName
import org.jetbrains.kotlin.konan.blackboxtest.support.util.parseGTestListing import org.jetbrains.kotlin.konan.blackboxtest.support.util.parseGTestListing
import org.junit.jupiter.api.Assertions.* import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.Tag
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
@Suppress("ClassName") @Suppress("ClassName")
@Tag("infrastructure")
class TestInfra_TestListingTest { class TestInfra_TestListingTest {
@Test @Test
fun successfullyParsed() = assertEquals( fun successfullyParsed() = assertEquals(