[Native][tests] Run stdlib tests with & without workers

This commit is contained in:
Dmitriy Dolovov
2021-12-06 23:22:51 +03:00
parent 3e54bb06ee
commit 50d766166b
5 changed files with 44 additions and 11 deletions
@@ -8,6 +8,7 @@
package org.jetbrains.kotlin.konan.blackboxtest
import org.jetbrains.kotlin.konan.blackboxtest.support.TestCaseId
import org.jetbrains.kotlin.konan.blackboxtest.support.TestRunnerType
import org.jetbrains.kotlin.konan.blackboxtest.support.group.PredefinedPaths.KOTLIN_NATIVE_DISTRIBUTION
import org.jetbrains.kotlin.konan.blackboxtest.support.group.PredefinedTestCase as TC
import org.jetbrains.kotlin.konan.blackboxtest.support.group.PredefinedTestCases
@@ -18,11 +19,20 @@ import org.junit.jupiter.api.TestFactory
@PredefinedTestCases(
TC(
name = "nativeStdlib",
freeCompilerArgs = [
"-Xmulti-platform",
"-friend-modules=$KOTLIN_NATIVE_STDLIB_PATH",
"-opt-in=kotlin.RequiresOptIn,kotlin.ExperimentalStdlibApi"
],
runnerType = TestRunnerType.DEFAULT,
freeCompilerArgs = [ENABLE_MPP, STDLIB_IS_A_FRIEND, ENABLE_X_STDLIB_API],
sourceLocations = [
"libraries/stdlib/test/**.kt",
"libraries/stdlib/common/test/**.kt",
"kotlin-native/backend.native/tests/stdlib_external/text/**.kt",
"kotlin-native/backend.native/tests/stdlib_external/utils.kt",
"kotlin-native/backend.native/tests/stdlib_external/jsCollectionFactoriesActuals.kt"
]
),
TC(
name = "nativeStdlibInWorker",
runnerType = TestRunnerType.WORKER,
freeCompilerArgs = [ENABLE_MPP, STDLIB_IS_A_FRIEND, ENABLE_X_STDLIB_API],
sourceLocations = [
"libraries/stdlib/test/**.kt",
"libraries/stdlib/common/test/**.kt",
@@ -33,7 +43,14 @@ import org.junit.jupiter.api.TestFactory
),
TC(
name = "kotlinTest",
freeCompilerArgs = ["-friend-modules=$KOTLIN_NATIVE_STDLIB_PATH"],
runnerType = TestRunnerType.DEFAULT,
freeCompilerArgs = [STDLIB_IS_A_FRIEND],
sourceLocations = ["libraries/kotlin.test/common/src/test/kotlin/**.kt"]
),
TC(
name = "kotlinTestInWorker",
runnerType = TestRunnerType.WORKER,
freeCompilerArgs = [STDLIB_IS_A_FRIEND],
sourceLocations = ["libraries/kotlin.test/common/src/test/kotlin/**.kt"]
)
)
@@ -41,8 +58,16 @@ class NativeStdlibBlackBoxTest : AbstractNativeBlackBoxTest() {
@TestFactory
fun kotlinTest() = dynamicTestCase(TestCaseId.Named("kotlinTest"))
@TestFactory
fun kotlinTestInWorker() = dynamicTestCase(TestCaseId.Named("kotlinTestInWorker"))
@TestFactory
fun nativeStdlib() = dynamicTestCase(TestCaseId.Named("nativeStdlib"))
@TestFactory
fun nativeStdlibInWorker() = dynamicTestCase(TestCaseId.Named("nativeStdlibInWorker"))
}
private const val KOTLIN_NATIVE_STDLIB_PATH = "$KOTLIN_NATIVE_DISTRIBUTION/klib/common/stdlib"
private const val ENABLE_MPP = "-Xmulti-platform"
private const val STDLIB_IS_A_FRIEND = "-friend-modules=$KOTLIN_NATIVE_DISTRIBUTION/klib/common/stdlib"
private const val ENABLE_X_STDLIB_API = "-opt-in=kotlin.RequiresOptIn,kotlin.ExperimentalStdlibApi"
@@ -38,7 +38,9 @@ class TestInfra_TestListingTest {
).map(::TestName),
parseGTestListing(
"""
|Seed: 12345
|Seed: 123
|Seed: 456
|Seed: -789
|Foo.
| bar
| baz
@@ -58,7 +58,7 @@ internal class PredefinedTestCaseGroupProvider(private val settings: Settings, a
.parseCompilerArgs { "Failed to parse free compiler arguments for test case $testCaseId" },
nominalPackageName = PackageName(testCaseId.uniqueName),
expectedOutputDataFile = null,
extras = WithTestRunnerExtras(runnerType = TestRunnerType.DEFAULT) // TODO: pass TR from the predefined configuration here
extras = WithTestRunnerExtras(runnerType = predefinedTestCase.runnerType)
)
testCase.initialize(null)
@@ -5,6 +5,7 @@
package org.jetbrains.kotlin.konan.blackboxtest.support.group
import org.jetbrains.kotlin.konan.blackboxtest.support.TestRunnerType
import org.jetbrains.kotlin.konan.blackboxtest.support.settings.TestSettings
@Target(AnnotationTarget.CLASS)
@@ -12,7 +13,12 @@ import org.jetbrains.kotlin.konan.blackboxtest.support.settings.TestSettings
internal annotation class PredefinedTestCases(vararg val testCases: PredefinedTestCase)
@Target()
internal annotation class PredefinedTestCase(val name: String, val freeCompilerArgs: Array<String>, val sourceLocations: Array<String>)
internal annotation class PredefinedTestCase(
val name: String,
val runnerType: TestRunnerType,
val freeCompilerArgs: Array<String>,
val sourceLocations: Array<String>
)
internal object PredefinedPaths {
const val KOTLIN_NATIVE_DISTRIBUTION = "\$KOTLIN_NATIVE_DISTRIBUTION\$"
@@ -39,7 +39,7 @@ internal fun parseGTestListing(listing: String): Collection<TestName> = buildLis
fun parseError(message: String): Nothing = parseError(message, index, line)
state = when {
index == 0 && line.startsWith(STDLIB_TESTS_IGNORED_LINE_PREFIX) -> state
line.startsWith(STDLIB_TESTS_IGNORED_LINE_PREFIX) && state is State.Begin -> State.Begin
line.isBlank() -> when (state) {
is State.NewTest, is State.End -> State.End
else -> parseError("Unexpected empty line")