[Native][tests] Fix: Avoid including similar but mutually exclusive shared modules into the same compilation
This commit is contained in:
+35
-9
@@ -105,7 +105,7 @@ internal sealed class TestModule {
|
||||
other.directDependencySymbols == directDependencySymbols && other.directFriendSymbols == directFriendSymbols
|
||||
}
|
||||
|
||||
class Shared(override val name: String) : TestModule() {
|
||||
data class Shared(override val name: String) : TestModule() {
|
||||
override val files: FailOnDuplicatesSet<TestFile<Shared>> = FailOnDuplicatesSet()
|
||||
}
|
||||
|
||||
@@ -210,6 +210,17 @@ internal class TestCase(
|
||||
rootModules as Set<TestModule.Exclusive>
|
||||
}
|
||||
|
||||
// All shared modules used in the current test case.
|
||||
val sharedModules: Set<TestModule.Shared> by lazy {
|
||||
buildSet {
|
||||
modules.forEach { module ->
|
||||
module.allDependencies.forEach { dependency ->
|
||||
if (dependency is TestModule.Shared) this += dependency
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun initialize(findSharedModule: ((moduleName: String) -> TestModule.Shared?)?) {
|
||||
// Check that there are no duplicated files among different modules.
|
||||
val duplicatedFiles = modules.flatMap { it.files }.groupingBy { it }.eachCount().filterValues { it > 1 }.keys
|
||||
@@ -253,7 +264,12 @@ internal interface TestCaseGroupId {
|
||||
internal interface TestCaseGroup {
|
||||
fun isEnabled(testCaseId: TestCaseId): Boolean
|
||||
fun getByName(testCaseId: TestCaseId): TestCase?
|
||||
fun getRegularOnly(freeCompilerArgs: TestCompilerArgs, runnerType: TestRunnerType): Collection<TestCase>
|
||||
|
||||
fun getRegularOnly(
|
||||
freeCompilerArgs: TestCompilerArgs,
|
||||
sharedModules: Set<TestModule.Shared>,
|
||||
runnerType: TestRunnerType
|
||||
): Collection<TestCase>
|
||||
|
||||
class Default(
|
||||
private val disabledTestCaseIds: Set<TestCaseId>,
|
||||
@@ -264,19 +280,29 @@ internal interface TestCaseGroup {
|
||||
override fun isEnabled(testCaseId: TestCaseId) = testCaseId !in disabledTestCaseIds
|
||||
override fun getByName(testCaseId: TestCaseId) = testCasesById[testCaseId]
|
||||
|
||||
override fun getRegularOnly(freeCompilerArgs: TestCompilerArgs, runnerType: TestRunnerType) =
|
||||
testCasesById.values.filter { testCase ->
|
||||
testCase.kind == TestKind.REGULAR
|
||||
&& testCase.extras<WithTestRunnerExtras>().runnerType == runnerType
|
||||
&& testCase.freeCompilerArgs == freeCompilerArgs
|
||||
}
|
||||
override fun getRegularOnly(
|
||||
freeCompilerArgs: TestCompilerArgs,
|
||||
sharedModules: Set<TestModule.Shared>,
|
||||
runnerType: TestRunnerType
|
||||
) = testCasesById.values.filter { testCase ->
|
||||
testCase.kind == TestKind.REGULAR
|
||||
&& testCase.freeCompilerArgs == freeCompilerArgs
|
||||
&& testCase.sharedModules == sharedModules
|
||||
&& testCase.extras<WithTestRunnerExtras>().runnerType == runnerType
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
val ALL_DISABLED = object : TestCaseGroup {
|
||||
override fun isEnabled(testCaseId: TestCaseId) = false
|
||||
override fun getByName(testCaseId: TestCaseId) = unsupported()
|
||||
override fun getRegularOnly(freeCompilerArgs: TestCompilerArgs, runnerType: TestRunnerType) = unsupported()
|
||||
|
||||
override fun getRegularOnly(
|
||||
freeCompilerArgs: TestCompilerArgs,
|
||||
sharedModules: Set<TestModule.Shared>,
|
||||
runnerType: TestRunnerType
|
||||
) = unsupported()
|
||||
|
||||
private fun unsupported(): Nothing = fail { "This function should not be called" }
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -145,10 +145,11 @@ internal class TestRunProvider(
|
||||
TestCompilationCacheKey.Grouped(
|
||||
testCaseGroupId = testCaseId.testCaseGroupId,
|
||||
freeCompilerArgs = testCase.freeCompilerArgs,
|
||||
sharedModules = testCase.sharedModules,
|
||||
runnerType = testRunnerType
|
||||
)
|
||||
) {
|
||||
val testCases = testCaseGroup.getRegularOnly(testCase.freeCompilerArgs, testRunnerType)
|
||||
val testCases = testCaseGroup.getRegularOnly(testCase.freeCompilerArgs, testCase.sharedModules, testRunnerType)
|
||||
assertTrue(testCases.isNotEmpty())
|
||||
compilationFactory.testCasesToExecutable(testCases, settings)
|
||||
}
|
||||
@@ -180,6 +181,7 @@ internal class TestRunProvider(
|
||||
data class Grouped(
|
||||
val testCaseGroupId: TestCaseGroupId,
|
||||
val freeCompilerArgs: TestCompilerArgs,
|
||||
val sharedModules: Set<TestModule.Shared>,
|
||||
val runnerType: TestRunnerType
|
||||
) : TestCompilationCacheKey()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user