[Native][tests] Add "force standalone tests" mode
This commit is contained in:
@@ -49,6 +49,7 @@ enum class TestProperty(shortName: String) {
|
|||||||
COMPILER_CLASSPATH("compilerClasspath"),
|
COMPILER_CLASSPATH("compilerClasspath"),
|
||||||
TEST_TARGET("target"),
|
TEST_TARGET("target"),
|
||||||
TEST_MODE("mode"),
|
TEST_MODE("mode"),
|
||||||
|
FORCE_STANDALONE("forceStandalone"),
|
||||||
OPTIMIZATION_MODE("optimizationMode"),
|
OPTIMIZATION_MODE("optimizationMode"),
|
||||||
MEMORY_MODEL("memoryModel"),
|
MEMORY_MODEL("memoryModel"),
|
||||||
USE_THREAD_STATE_CHECKER("useThreadStateChecker"),
|
USE_THREAD_STATE_CHECKER("useThreadStateChecker"),
|
||||||
@@ -115,6 +116,7 @@ fun nativeTest(taskName: String, vararg tags: String) = projectTest(taskName, jU
|
|||||||
// Pass Gradle properties as JVM properties so test process can read them.
|
// Pass Gradle properties as JVM properties so test process can read them.
|
||||||
TestProperty.TEST_TARGET.setUpFromGradleProperty(this)
|
TestProperty.TEST_TARGET.setUpFromGradleProperty(this)
|
||||||
TestProperty.TEST_MODE.setUpFromGradleProperty(this)
|
TestProperty.TEST_MODE.setUpFromGradleProperty(this)
|
||||||
|
TestProperty.FORCE_STANDALONE.setUpFromGradleProperty(this)
|
||||||
TestProperty.OPTIMIZATION_MODE.setUpFromGradleProperty(this)
|
TestProperty.OPTIMIZATION_MODE.setUpFromGradleProperty(this)
|
||||||
TestProperty.MEMORY_MODEL.setUpFromGradleProperty(this)
|
TestProperty.MEMORY_MODEL.setUpFromGradleProperty(this)
|
||||||
TestProperty.USE_THREAD_STATE_CHECKER.setUpFromGradleProperty(this)
|
TestProperty.USE_THREAD_STATE_CHECKER.setUpFromGradleProperty(this)
|
||||||
|
|||||||
+1
@@ -43,6 +43,7 @@ internal class EnforcedProperties(testClass: Class<*>) {
|
|||||||
internal enum class ClassLevelProperty(shortName: String) {
|
internal enum class ClassLevelProperty(shortName: String) {
|
||||||
TEST_TARGET("target"),
|
TEST_TARGET("target"),
|
||||||
TEST_MODE("mode"),
|
TEST_MODE("mode"),
|
||||||
|
FORCE_STANDALONE("forceStandalone"),
|
||||||
OPTIMIZATION_MODE("optimizationMode"),
|
OPTIMIZATION_MODE("optimizationMode"),
|
||||||
MEMORY_MODEL("memoryModel"),
|
MEMORY_MODEL("memoryModel"),
|
||||||
USE_THREAD_STATE_CHECKER("useThreadStateChecker"),
|
USE_THREAD_STATE_CHECKER("useThreadStateChecker"),
|
||||||
|
|||||||
+10
@@ -158,6 +158,7 @@ private object NativeTestSupport {
|
|||||||
output += nativeTargets
|
output += nativeTargets
|
||||||
output += CacheMode::class to cacheMode
|
output += CacheMode::class to cacheMode
|
||||||
output += computeTestMode(enforcedProperties)
|
output += computeTestMode(enforcedProperties)
|
||||||
|
output += computeForcedStandaloneTestKind(enforcedProperties)
|
||||||
output += computeTimeouts(enforcedProperties)
|
output += computeTimeouts(enforcedProperties)
|
||||||
|
|
||||||
return nativeTargets
|
return nativeTargets
|
||||||
@@ -220,6 +221,15 @@ private object NativeTestSupport {
|
|||||||
private fun computeTestMode(enforcedProperties: EnforcedProperties): TestMode =
|
private fun computeTestMode(enforcedProperties: EnforcedProperties): TestMode =
|
||||||
ClassLevelProperty.TEST_MODE.readValue(enforcedProperties, TestMode.values(), default = TestMode.TWO_STAGE_MULTI_MODULE)
|
ClassLevelProperty.TEST_MODE.readValue(enforcedProperties, TestMode.values(), default = TestMode.TWO_STAGE_MULTI_MODULE)
|
||||||
|
|
||||||
|
private fun computeForcedStandaloneTestKind(enforcedProperties: EnforcedProperties): ForcedStandaloneTestKind =
|
||||||
|
ForcedStandaloneTestKind(
|
||||||
|
ClassLevelProperty.FORCE_STANDALONE.readValue(
|
||||||
|
enforcedProperties,
|
||||||
|
String::toBooleanStrictOrNull,
|
||||||
|
default = false
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
private fun computeTimeouts(enforcedProperties: EnforcedProperties): Timeouts {
|
private fun computeTimeouts(enforcedProperties: EnforcedProperties): Timeouts {
|
||||||
val executionTimeout = ClassLevelProperty.EXECUTION_TIMEOUT.readValue(
|
val executionTimeout = ClassLevelProperty.EXECUTION_TIMEOUT.readValue(
|
||||||
enforcedProperties,
|
enforcedProperties,
|
||||||
|
|||||||
+3
-2
@@ -73,7 +73,7 @@ internal class ExtTestCaseGroupProvider : TestCaseGroupProvider, TestDisposable(
|
|||||||
|
|
||||||
if (extTestDataFile.isRelevant)
|
if (extTestDataFile.isRelevant)
|
||||||
testCases += extTestDataFile.createTestCase(
|
testCases += extTestDataFile.createTestCase(
|
||||||
definitelyStandaloneTest = testDataFile in standalones,
|
definitelyStandaloneTest = settings.get<ForcedStandaloneTestKind>().value || testDataFile in standalones,
|
||||||
sharedModules = sharedModules
|
sharedModules = sharedModules
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
@@ -168,7 +168,8 @@ private class ExtTestDataFile(
|
|||||||
return doCreateTestCase(isStandaloneTest, sharedModules)
|
return doCreateTestCase(isStandaloneTest, sharedModules)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Determine if the current test should be compiled as a standalone test, i.e.
|
/**
|
||||||
|
* Determine if the current test should be compiled as a standalone test, i.e.
|
||||||
* - package names are not patched
|
* - package names are not patched
|
||||||
* - test is compiled independently of any other tests
|
* - test is compiled independently of any other tests
|
||||||
*/
|
*/
|
||||||
|
|||||||
+8
-5
@@ -10,10 +10,7 @@ import org.jetbrains.kotlin.konan.blackboxtest.support.TestCase.NoTestRunnerExtr
|
|||||||
import org.jetbrains.kotlin.konan.blackboxtest.support.TestCase.WithTestRunnerExtras
|
import org.jetbrains.kotlin.konan.blackboxtest.support.TestCase.WithTestRunnerExtras
|
||||||
import org.jetbrains.kotlin.konan.blackboxtest.support.runner.TestRunCheck.*
|
import org.jetbrains.kotlin.konan.blackboxtest.support.runner.TestRunCheck.*
|
||||||
import org.jetbrains.kotlin.konan.blackboxtest.support.runner.TestRunChecks
|
import org.jetbrains.kotlin.konan.blackboxtest.support.runner.TestRunChecks
|
||||||
import org.jetbrains.kotlin.konan.blackboxtest.support.settings.GeneratedSources
|
import org.jetbrains.kotlin.konan.blackboxtest.support.settings.*
|
||||||
import org.jetbrains.kotlin.konan.blackboxtest.support.settings.Settings
|
|
||||||
import org.jetbrains.kotlin.konan.blackboxtest.support.settings.TestRoots
|
|
||||||
import org.jetbrains.kotlin.konan.blackboxtest.support.settings.Timeouts
|
|
||||||
import org.jetbrains.kotlin.konan.blackboxtest.support.util.*
|
import org.jetbrains.kotlin.konan.blackboxtest.support.util.*
|
||||||
import org.jetbrains.kotlin.test.directives.model.Directive
|
import org.jetbrains.kotlin.test.directives.model.Directive
|
||||||
import org.jetbrains.kotlin.test.directives.model.RegisteredDirectives
|
import org.jetbrains.kotlin.test.directives.model.RegisteredDirectives
|
||||||
@@ -182,9 +179,15 @@ internal class StandardTestCaseGroupProvider : TestCaseGroupProvider {
|
|||||||
val registeredDirectives = directivesParser.build()
|
val registeredDirectives = directivesParser.build()
|
||||||
|
|
||||||
val freeCompilerArgs = parseFreeCompilerArgs(registeredDirectives, location)
|
val freeCompilerArgs = parseFreeCompilerArgs(registeredDirectives, location)
|
||||||
val testKind = parseTestKind(registeredDirectives, location)
|
|
||||||
val expectedTimeoutFailure = parseExpectedTimeoutFailure(registeredDirectives)
|
val expectedTimeoutFailure = parseExpectedTimeoutFailure(registeredDirectives)
|
||||||
|
|
||||||
|
val testKind = parseTestKind(registeredDirectives, location).let { testKind ->
|
||||||
|
if (testKind == TestKind.REGULAR && settings.get<ForcedStandaloneTestKind>().value)
|
||||||
|
TestKind.STANDALONE
|
||||||
|
else
|
||||||
|
testKind
|
||||||
|
}
|
||||||
|
|
||||||
if (testKind == TestKind.REGULAR) {
|
if (testKind == TestKind.REGULAR) {
|
||||||
// Fix package declarations to avoid unintended conflicts between symbols with the same name in different test cases.
|
// Fix package declarations to avoid unintended conflicts between symbols with the same name in different test cases.
|
||||||
fixPackageNames(testModules.values, nominalPackageName, testDataFile)
|
fixPackageNames(testModules.values, nominalPackageName, testDataFile)
|
||||||
|
|||||||
+9
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.konan.blackboxtest.support.settings
|
package org.jetbrains.kotlin.konan.blackboxtest.support.settings
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.konan.blackboxtest.support.TestKind
|
||||||
import org.jetbrains.kotlin.konan.target.KonanTarget
|
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||||
import org.jetbrains.kotlin.test.services.JUnit5Assertions.assertTrue
|
import org.jetbrains.kotlin.test.services.JUnit5Assertions.assertTrue
|
||||||
import java.io.File
|
import java.io.File
|
||||||
@@ -54,6 +55,14 @@ internal enum class TestMode(private val description: String) {
|
|||||||
override fun toString() = description
|
override fun toString() = description
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether to force [TestKind.STANDALONE] for all tests where [TestKind] is assumed to be [TestKind.REGULAR] otherwise:
|
||||||
|
* - either explicitly specified in the test data file: // KIND: REGULAR
|
||||||
|
* - or // KIND: is not specified in the test data file and thus automatically considered as [TestKind.REGULAR]
|
||||||
|
*/
|
||||||
|
@JvmInline
|
||||||
|
internal value class ForcedStandaloneTestKind(val value: Boolean)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optimization mode to be applied.
|
* Optimization mode to be applied.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user