From 50d766166ba1fed047be228c3815fe2aaa1dffe3 Mon Sep 17 00:00:00 2001 From: Dmitriy Dolovov Date: Mon, 6 Dec 2021 23:22:51 +0300 Subject: [PATCH] [Native][tests] Run stdlib tests with & without workers --- .../blackboxtest/NativeStdlibBlackBoxTest.kt | 39 +++++++++++++++---- .../blackboxtest/TestInfra_TestListingTest.kt | 4 +- .../group/PredefinedTestCaseGroupProvider.kt | 2 +- .../support/group/PredefinedTestCases.kt | 8 +++- .../blackboxtest/support/util/TestListing.kt | 2 +- 5 files changed, 44 insertions(+), 11 deletions(-) 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 7ef6a0d06de..022eabba8e0 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 @@ -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" 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 d5f39c6c544..ca695ccf55c 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 @@ -38,7 +38,9 @@ class TestInfra_TestListingTest { ).map(::TestName), parseGTestListing( """ - |Seed: 12345 + |Seed: 123 + |Seed: 456 + |Seed: -789 |Foo. | bar | baz diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/support/group/PredefinedTestCaseGroupProvider.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/support/group/PredefinedTestCaseGroupProvider.kt index e049425acc2..99c618920c5 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/support/group/PredefinedTestCaseGroupProvider.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/support/group/PredefinedTestCaseGroupProvider.kt @@ -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) diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/support/group/PredefinedTestCases.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/support/group/PredefinedTestCases.kt index ae1f049da79..b417ead357c 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/support/group/PredefinedTestCases.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/support/group/PredefinedTestCases.kt @@ -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, val sourceLocations: Array) +internal annotation class PredefinedTestCase( + val name: String, + val runnerType: TestRunnerType, + val freeCompilerArgs: Array, + val sourceLocations: Array +) internal object PredefinedPaths { const val KOTLIN_NATIVE_DISTRIBUTION = "\$KOTLIN_NATIVE_DISTRIBUTION\$" diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/support/util/TestListing.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/support/util/TestListing.kt index 8c312b2519e..9634d946cca 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/support/util/TestListing.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/support/util/TestListing.kt @@ -39,7 +39,7 @@ internal fun parseGTestListing(listing: String): Collection = 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")