[Native][Tests] Refactor CExport tests for future changes
1. Unify BinaryLibraryKind type and move it to TestSettings 2. Pass it via ClassSettings instead of constructor parameters. 3. Update GenerateNativeTests.kt to generate CExport tests as a matrix.
This commit is contained in:
committed by
Space Team
parent
9606a5a441
commit
06c0977408
+4
-1
@@ -7,6 +7,8 @@ package org.jetbrains.kotlin.konan.test.blackbox;
|
|||||||
|
|
||||||
import com.intellij.testFramework.TestDataPath;
|
import com.intellij.testFramework.TestDataPath;
|
||||||
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
||||||
|
import org.jetbrains.kotlin.konan.test.blackbox.support.EnforcedProperty;
|
||||||
|
import org.jetbrains.kotlin.konan.test.blackbox.support.ClassLevelProperty;
|
||||||
import org.jetbrains.kotlin.test.TestMetadata;
|
import org.jetbrains.kotlin.test.TestMetadata;
|
||||||
import org.junit.jupiter.api.Nested;
|
import org.junit.jupiter.api.Nested;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@@ -18,7 +20,8 @@ import java.util.regex.Pattern;
|
|||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
@TestMetadata("native/native.tests/testData/CExport")
|
@TestMetadata("native/native.tests/testData/CExport")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
public class CExportTestStaticGenerated extends AbstractNativeCExportStaticTest {
|
@EnforcedProperty(property = ClassLevelProperty.BINARY_LIBRARY_KIND, propertyValue = "DYNAMIC")
|
||||||
|
public class CExportDynamicTestGenerated extends AbstractNativeCExportTest {
|
||||||
@Test
|
@Test
|
||||||
public void testAllFilesPresentInCExport() {
|
public void testAllFilesPresentInCExport() {
|
||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/CExport"), Pattern.compile("^([^_](.+))$"), null, false);
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/CExport"), Pattern.compile("^([^_](.+))$"), null, false);
|
||||||
+4
-1
@@ -7,6 +7,8 @@ package org.jetbrains.kotlin.konan.test.blackbox;
|
|||||||
|
|
||||||
import com.intellij.testFramework.TestDataPath;
|
import com.intellij.testFramework.TestDataPath;
|
||||||
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
||||||
|
import org.jetbrains.kotlin.konan.test.blackbox.support.EnforcedProperty;
|
||||||
|
import org.jetbrains.kotlin.konan.test.blackbox.support.ClassLevelProperty;
|
||||||
import org.jetbrains.kotlin.test.TestMetadata;
|
import org.jetbrains.kotlin.test.TestMetadata;
|
||||||
import org.junit.jupiter.api.Nested;
|
import org.junit.jupiter.api.Nested;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@@ -18,7 +20,8 @@ import java.util.regex.Pattern;
|
|||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
@TestMetadata("native/native.tests/testData/CExport")
|
@TestMetadata("native/native.tests/testData/CExport")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
public class CExportTestDynamicGenerated extends AbstractNativeCExportDynamicTest {
|
@EnforcedProperty(property = ClassLevelProperty.BINARY_LIBRARY_KIND, propertyValue = "STATIC")
|
||||||
|
public class CExportStaticTestGenerated extends AbstractNativeCExportTest {
|
||||||
@Test
|
@Test
|
||||||
public void testAllFilesPresentInCExport() {
|
public void testAllFilesPresentInCExport() {
|
||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/CExport"), Pattern.compile("^([^_](.+))$"), null, false);
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/CExport"), Pattern.compile("^([^_](.+))$"), null, false);
|
||||||
+5
-2
@@ -7,6 +7,8 @@ package org.jetbrains.kotlin.konan.test.blackbox;
|
|||||||
|
|
||||||
import com.intellij.testFramework.TestDataPath;
|
import com.intellij.testFramework.TestDataPath;
|
||||||
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
||||||
|
import org.jetbrains.kotlin.konan.test.blackbox.support.EnforcedProperty;
|
||||||
|
import org.jetbrains.kotlin.konan.test.blackbox.support.ClassLevelProperty;
|
||||||
import org.junit.jupiter.api.Tag;
|
import org.junit.jupiter.api.Tag;
|
||||||
import org.jetbrains.kotlin.konan.test.blackbox.support.group.FirPipeline;
|
import org.jetbrains.kotlin.konan.test.blackbox.support.group.FirPipeline;
|
||||||
import org.jetbrains.kotlin.test.TestMetadata;
|
import org.jetbrains.kotlin.test.TestMetadata;
|
||||||
@@ -20,11 +22,12 @@ import java.util.regex.Pattern;
|
|||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
@TestMetadata("native/native.tests/testData/CExport")
|
@TestMetadata("native/native.tests/testData/CExport")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@EnforcedProperty(property = ClassLevelProperty.BINARY_LIBRARY_KIND, propertyValue = "DYNAMIC")
|
||||||
@Tag("frontend-fir")
|
@Tag("frontend-fir")
|
||||||
@FirPipeline()
|
@FirPipeline()
|
||||||
public class FirCExportTestStaticGenerated extends AbstractNativeCExportStaticTest {
|
public class FirCExportDynamicTestGenerated extends AbstractNativeCExportTest {
|
||||||
@Test
|
@Test
|
||||||
public void testAllFilesPresentInCExport() {
|
public void testAllFilesPresentInCExport() throws Exception {
|
||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/CExport"), Pattern.compile("^([^_](.+))$"), null, false);
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/CExport"), Pattern.compile("^([^_](.+))$"), null, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
+4
-2
@@ -7,6 +7,8 @@ package org.jetbrains.kotlin.konan.test.blackbox;
|
|||||||
|
|
||||||
import com.intellij.testFramework.TestDataPath;
|
import com.intellij.testFramework.TestDataPath;
|
||||||
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
||||||
|
import org.jetbrains.kotlin.konan.test.blackbox.support.EnforcedProperty;
|
||||||
|
import org.jetbrains.kotlin.konan.test.blackbox.support.ClassLevelProperty;
|
||||||
import org.junit.jupiter.api.Tag;
|
import org.junit.jupiter.api.Tag;
|
||||||
import org.jetbrains.kotlin.konan.test.blackbox.support.group.FirPipeline;
|
import org.jetbrains.kotlin.konan.test.blackbox.support.group.FirPipeline;
|
||||||
import org.jetbrains.kotlin.test.TestMetadata;
|
import org.jetbrains.kotlin.test.TestMetadata;
|
||||||
@@ -22,9 +24,9 @@ import java.util.regex.Pattern;
|
|||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@Tag("frontend-fir")
|
@Tag("frontend-fir")
|
||||||
@FirPipeline()
|
@FirPipeline()
|
||||||
public class FirCExportTestDynamicGenerated extends AbstractNativeCExportDynamicTest {
|
public class FirCExportStaticTestGenerated extends AbstractNativeCExportTest {
|
||||||
@Test
|
@Test
|
||||||
public void testAllFilesPresentInCExport() {
|
public void testAllFilesPresentInCExport() throws Exception {
|
||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/CExport"), Pattern.compile("^([^_](.+))$"), null, false);
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/CExport"), Pattern.compile("^([^_](.+))$"), null, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
+27
-25
@@ -459,33 +459,30 @@ fun main() {
|
|||||||
model("standalone")
|
model("standalone")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
val binaryLibraryKinds = mapOf(
|
||||||
|
"Static" to binaryLibraryKind("STATIC"),
|
||||||
|
"Dynamic" to binaryLibraryKind("DYNAMIC"),
|
||||||
|
)
|
||||||
|
val frontendFlags = mapOf(
|
||||||
|
"Classic" to arrayOf(),
|
||||||
|
"Fir" to frontendFir(),
|
||||||
|
)
|
||||||
// C Export
|
// C Export
|
||||||
testGroup("native/native.tests/tests-gen", "native/native.tests/testData") {
|
testGroup("native/native.tests/tests-gen", "native/native.tests/testData") {
|
||||||
testClass<AbstractNativeCExportDynamicTest>(
|
binaryLibraryKinds.forEach { binaryKind ->
|
||||||
suiteTestClassName = "CExportTestDynamicGenerated"
|
frontendFlags.forEach { frontend ->
|
||||||
) {
|
val frontendKey = if (frontend.key == "Classic") "" else frontend.key
|
||||||
model("CExport", pattern = "^([^_](.+))$", recursive = false)
|
val suiteTestClassName = "${frontendKey}CExport${binaryKind.key}TestGenerated"
|
||||||
}
|
testClass<AbstractNativeCExportTest>(
|
||||||
testClass<AbstractNativeCExportDynamicTest>(
|
suiteTestClassName,
|
||||||
suiteTestClassName = "FirCExportTestDynamicGenerated",
|
annotations = listOf(
|
||||||
annotations = listOf(
|
binaryKind.value,
|
||||||
*frontendFir()
|
*frontend.value
|
||||||
),
|
)
|
||||||
) {
|
) {
|
||||||
model("CExport", pattern = "^([^_](.+))$", recursive = false)
|
model("CExport", pattern = "^([^_](.+))$", recursive = false)
|
||||||
}
|
}
|
||||||
testClass<AbstractNativeCExportStaticTest>(
|
}
|
||||||
suiteTestClassName = "CExportTestStaticGenerated"
|
|
||||||
) {
|
|
||||||
model("CExport", pattern = "^([^_](.+))$", recursive = false)
|
|
||||||
}
|
|
||||||
testClass<AbstractNativeCExportStaticTest>(
|
|
||||||
suiteTestClassName = "FirCExportTestStaticGenerated",
|
|
||||||
annotations = listOf(
|
|
||||||
*frontendFir()
|
|
||||||
),
|
|
||||||
) {
|
|
||||||
model("CExport", pattern = "^([^_](.+))$", recursive = false)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Swift Export
|
// Swift Export
|
||||||
@@ -564,3 +561,8 @@ private fun standalone() = arrayOf(
|
|||||||
"propertyValue" to "STANDALONE_NO_TR"
|
"propertyValue" to "STANDALONE_NO_TR"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
private fun binaryLibraryKind(kind: String = "DYNAMIC") = annotation(
|
||||||
|
EnforcedProperty::class.java,
|
||||||
|
"property" to ClassLevelProperty.BINARY_LIBRARY_KIND,
|
||||||
|
"propertyValue" to kind
|
||||||
|
)
|
||||||
|
|||||||
+25
-34
@@ -21,6 +21,7 @@ import org.jetbrains.kotlin.konan.test.blackbox.support.compilation.TestCompilat
|
|||||||
import org.jetbrains.kotlin.konan.test.blackbox.support.runner.TestExecutable
|
import org.jetbrains.kotlin.konan.test.blackbox.support.runner.TestExecutable
|
||||||
import org.jetbrains.kotlin.konan.test.blackbox.support.runner.TestRunCheck
|
import org.jetbrains.kotlin.konan.test.blackbox.support.runner.TestRunCheck
|
||||||
import org.jetbrains.kotlin.konan.test.blackbox.support.runner.TestRunChecks
|
import org.jetbrains.kotlin.konan.test.blackbox.support.runner.TestRunChecks
|
||||||
|
import org.jetbrains.kotlin.konan.test.blackbox.support.settings.BinaryLibraryKind
|
||||||
import org.jetbrains.kotlin.konan.test.blackbox.support.settings.KotlinNativeTargets
|
import org.jetbrains.kotlin.konan.test.blackbox.support.settings.KotlinNativeTargets
|
||||||
import org.jetbrains.kotlin.konan.test.blackbox.support.settings.Timeouts
|
import org.jetbrains.kotlin.konan.test.blackbox.support.settings.Timeouts
|
||||||
import org.jetbrains.kotlin.konan.test.blackbox.support.settings.configurables
|
import org.jetbrains.kotlin.konan.test.blackbox.support.settings.configurables
|
||||||
@@ -33,17 +34,33 @@ import org.junit.jupiter.api.Tag
|
|||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
@Tag("cexport")
|
@Tag("cexport")
|
||||||
abstract class AbstractNativeCExportTest(
|
abstract class AbstractNativeCExportTest() : AbstractNativeSimpleTest() {
|
||||||
protected val libraryKind: BinaryLibraryKind,
|
|
||||||
) : AbstractNativeSimpleTest() {
|
|
||||||
|
|
||||||
enum class BinaryLibraryKind {
|
private val libraryKind: BinaryLibraryKind by lazy {
|
||||||
STATIC, DYNAMIC
|
testRunSettings.get<BinaryLibraryKind>()
|
||||||
}
|
}
|
||||||
|
|
||||||
internal open fun getKindSpecificClangFlags(binaryLibrary: TestCompilationArtifact.BinaryLibrary): List<String> = emptyList()
|
private fun getKindSpecificClangFlags(binaryLibrary: TestCompilationArtifact.BinaryLibrary): List<String> = when (libraryKind) {
|
||||||
|
BinaryLibraryKind.STATIC -> testRunSettings.configurables.linkerKonanFlags.flatMap { listOf("-Xlinker", it) }
|
||||||
|
BinaryLibraryKind.DYNAMIC -> {
|
||||||
|
if (testRunSettings.get<KotlinNativeTargets>().testTarget.family != Family.MINGW) {
|
||||||
|
listOf("-rpath", binaryLibrary.libraryFile.parentFile.absolutePath)
|
||||||
|
} else {
|
||||||
|
// --allow-multiple-definition is needed because finalLinkCommands statically links a lot of MinGW-specific libraries,
|
||||||
|
// that are already included in DLL produced by Kotlin/Native.
|
||||||
|
listOf("-Wl,--allow-multiple-definition")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
internal open fun checkTestPrerequisites() {}
|
internal open fun checkTestPrerequisites() {
|
||||||
|
when (libraryKind) {
|
||||||
|
BinaryLibraryKind.STATIC -> if (targets.testTarget.family == Family.MINGW) {
|
||||||
|
Assumptions.abort<Nothing>("Testing of static libraries is not supported for MinGW targets.")
|
||||||
|
}
|
||||||
|
BinaryLibraryKind.DYNAMIC -> {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private val testCompilationFactory = TestCompilationFactory()
|
private val testCompilationFactory = TestCompilationFactory()
|
||||||
|
|
||||||
@@ -67,7 +84,7 @@ abstract class AbstractNativeCExportTest(
|
|||||||
val binaryLibrary = testCompilationFactory.testCaseToBinaryLibrary(
|
val binaryLibrary = testCompilationFactory.testCaseToBinaryLibrary(
|
||||||
testCase,
|
testCase,
|
||||||
testRunSettings,
|
testRunSettings,
|
||||||
kind = libraryKind.mapToArtifactKind(),
|
kind = libraryKind,
|
||||||
).result.assertSuccess().resultingArtifact
|
).result.assertSuccess().resultingArtifact
|
||||||
|
|
||||||
val clangExecutableName = "clangMain"
|
val clangExecutableName = "clangMain"
|
||||||
@@ -119,30 +136,4 @@ abstract class AbstractNativeCExportTest(
|
|||||||
initialize(null, null)
|
initialize(null, null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun BinaryLibraryKind.mapToArtifactKind(): TestCompilationArtifact.BinaryLibrary.Kind = when (this) {
|
|
||||||
BinaryLibraryKind.STATIC -> TestCompilationArtifact.BinaryLibrary.Kind.STATIC
|
|
||||||
BinaryLibraryKind.DYNAMIC -> TestCompilationArtifact.BinaryLibrary.Kind.DYNAMIC
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class AbstractNativeCExportStaticTest() : AbstractNativeCExportTest(libraryKind = BinaryLibraryKind.STATIC) {
|
|
||||||
override fun getKindSpecificClangFlags(binaryLibrary: TestCompilationArtifact.BinaryLibrary): List<String> =
|
|
||||||
testRunSettings.configurables.linkerKonanFlags.flatMap { listOf("-Xlinker", it) }
|
|
||||||
|
|
||||||
override fun checkTestPrerequisites() {
|
|
||||||
if (targets.testTarget.family == Family.MINGW) {
|
|
||||||
Assumptions.abort<Nothing>("Testing of static libraries is not supported for MinGW targets.")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
abstract class AbstractNativeCExportDynamicTest() : AbstractNativeCExportTest(libraryKind = BinaryLibraryKind.DYNAMIC) {
|
|
||||||
override fun getKindSpecificClangFlags(binaryLibrary: TestCompilationArtifact.BinaryLibrary): List<String> =
|
|
||||||
if (testRunSettings.get<KotlinNativeTargets>().testTarget.family != Family.MINGW) {
|
|
||||||
listOf("-rpath", binaryLibrary.libraryFile.parentFile.absolutePath)
|
|
||||||
} else {
|
|
||||||
// --allow-multiple-definition is needed because finalLinkCommands statically links a lot of MinGW-specific libraries,
|
|
||||||
// that are already included in DLL produced by Kotlin/Native.
|
|
||||||
listOf("-Wl,--allow-multiple-definition")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
+2
-1
@@ -21,6 +21,7 @@ import org.jetbrains.kotlin.konan.test.blackbox.support.compilation.TestCompilat
|
|||||||
import org.jetbrains.kotlin.konan.test.blackbox.support.runner.TestExecutable
|
import org.jetbrains.kotlin.konan.test.blackbox.support.runner.TestExecutable
|
||||||
import org.jetbrains.kotlin.konan.test.blackbox.support.runner.TestRunCheck
|
import org.jetbrains.kotlin.konan.test.blackbox.support.runner.TestRunCheck
|
||||||
import org.jetbrains.kotlin.konan.test.blackbox.support.runner.TestRunChecks
|
import org.jetbrains.kotlin.konan.test.blackbox.support.runner.TestRunChecks
|
||||||
|
import org.jetbrains.kotlin.konan.test.blackbox.support.settings.BinaryLibraryKind
|
||||||
import org.jetbrains.kotlin.konan.test.blackbox.support.settings.Timeouts
|
import org.jetbrains.kotlin.konan.test.blackbox.support.settings.Timeouts
|
||||||
import org.jetbrains.kotlin.konan.test.blackbox.support.util.DEFAULT_MODULE_NAME
|
import org.jetbrains.kotlin.konan.test.blackbox.support.util.DEFAULT_MODULE_NAME
|
||||||
import org.jetbrains.kotlin.konan.test.blackbox.support.util.createModuleMap
|
import org.jetbrains.kotlin.konan.test.blackbox.support.util.createModuleMap
|
||||||
@@ -48,7 +49,7 @@ abstract class AbstractNativeSwiftExportTest() : AbstractNativeSimpleTest() {
|
|||||||
val testCase = generateSwiftExportTestCase(testName, kotlinFiles + swiftExportOutput.kotlinBridges.toFile())
|
val testCase = generateSwiftExportTestCase(testName, kotlinFiles + swiftExportOutput.kotlinBridges.toFile())
|
||||||
val kotlinBinaryLibrary = testCompilationFactory.testCaseToBinaryLibrary(
|
val kotlinBinaryLibrary = testCompilationFactory.testCaseToBinaryLibrary(
|
||||||
testCase, testRunSettings,
|
testCase, testRunSettings,
|
||||||
kind = TestCompilationArtifact.BinaryLibrary.Kind.DYNAMIC,
|
kind = BinaryLibraryKind.DYNAMIC,
|
||||||
).result.assertSuccess().resultingArtifact
|
).result.assertSuccess().resultingArtifact
|
||||||
|
|
||||||
val bridgeModuleFile = createModuleMap(buildDir, swiftExportOutput.cHeaderBridges.toFile())
|
val bridgeModuleFile = createModuleMap(buildDir, swiftExportOutput.cHeaderBridges.toFile())
|
||||||
|
|||||||
+1
@@ -72,6 +72,7 @@ internal enum class ClassLevelProperty(val shortName: String) {
|
|||||||
COMPILER_OUTPUT_INTERCEPTOR("compilerOutputInterceptor"),
|
COMPILER_OUTPUT_INTERCEPTOR("compilerOutputInterceptor"),
|
||||||
PIPELINE_TYPE("pipelineType"),
|
PIPELINE_TYPE("pipelineType"),
|
||||||
SHARED_TEST_EXECUTION("sharedTestExecution"),
|
SHARED_TEST_EXECUTION("sharedTestExecution"),
|
||||||
|
BINARY_LIBRARY_KIND("binaryLibraryKind"),
|
||||||
;
|
;
|
||||||
|
|
||||||
internal val propertyName = fullPropertyName(shortName)
|
internal val propertyName = fullPropertyName(shortName)
|
||||||
|
|||||||
+3
@@ -209,6 +209,7 @@ internal object NativeTestSupport {
|
|||||||
output += computePipelineType(enforcedProperties, testClass.get())
|
output += computePipelineType(enforcedProperties, testClass.get())
|
||||||
output += computeUsedPartialLinkageConfig(enclosingTestClass)
|
output += computeUsedPartialLinkageConfig(enclosingTestClass)
|
||||||
output += computeCompilerOutputInterceptor(enforcedProperties)
|
output += computeCompilerOutputInterceptor(enforcedProperties)
|
||||||
|
output += computeBinaryLibraryKind(enforcedProperties)
|
||||||
|
|
||||||
return nativeTargets
|
return nativeTargets
|
||||||
}
|
}
|
||||||
@@ -505,6 +506,8 @@ internal object NativeTestSupport {
|
|||||||
return UsedPartialLinkageConfig(config)
|
return UsedPartialLinkageConfig(config)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun computeBinaryLibraryKind(enforcedProperties: EnforcedProperties): BinaryLibraryKind =
|
||||||
|
ClassLevelProperty.BINARY_LIBRARY_KIND.readValue(enforcedProperties, BinaryLibraryKind.values(), BinaryLibraryKind.STATIC)
|
||||||
/*************** Test class settings (simplified) ***************/
|
/*************** Test class settings (simplified) ***************/
|
||||||
|
|
||||||
private fun ExtensionContext.getOrCreateSimpleTestClassSettings(): SimpleTestClassSettings =
|
private fun ExtensionContext.getOrCreateSimpleTestClassSettings(): SimpleTestClassSettings =
|
||||||
|
|||||||
+5
-4
@@ -330,7 +330,8 @@ internal class BinaryLibraryCompilation(
|
|||||||
freeCompilerArgs: TestCompilerArgs,
|
freeCompilerArgs: TestCompilerArgs,
|
||||||
sourceModules: Collection<TestModule>,
|
sourceModules: Collection<TestModule>,
|
||||||
dependencies: Iterable<TestCompilationDependency<*>>,
|
dependencies: Iterable<TestCompilationDependency<*>>,
|
||||||
expectedArtifact: BinaryLibrary
|
expectedArtifact: BinaryLibrary,
|
||||||
|
private val kind: BinaryLibraryKind,
|
||||||
) : SourceBasedCompilation<BinaryLibrary>(
|
) : SourceBasedCompilation<BinaryLibrary>(
|
||||||
targets = settings.get(),
|
targets = settings.get(),
|
||||||
home = settings.get(),
|
home = settings.get(),
|
||||||
@@ -353,9 +354,9 @@ internal class BinaryLibraryCompilation(
|
|||||||
override val binaryOptions get() = BinaryOptions.RuntimeAssertionsMode.defaultForTesting(optimizationMode, freeCompilerArgs.assertionsMode)
|
override val binaryOptions get() = BinaryOptions.RuntimeAssertionsMode.defaultForTesting(optimizationMode, freeCompilerArgs.assertionsMode)
|
||||||
|
|
||||||
override fun applySpecificArgs(argsBuilder: ArgsBuilder) = with(argsBuilder) {
|
override fun applySpecificArgs(argsBuilder: ArgsBuilder) = with(argsBuilder) {
|
||||||
val libraryKind = when (expectedArtifact.kind) {
|
val libraryKind = when (kind) {
|
||||||
BinaryLibrary.Kind.STATIC -> "static"
|
BinaryLibraryKind.STATIC -> "static"
|
||||||
BinaryLibrary.Kind.DYNAMIC -> "dynamic"
|
BinaryLibraryKind.DYNAMIC -> "dynamic"
|
||||||
}
|
}
|
||||||
add(
|
add(
|
||||||
"-produce", libraryKind,
|
"-produce", libraryKind,
|
||||||
|
|||||||
+1
-5
@@ -40,11 +40,7 @@ internal sealed interface TestCompilationArtifact {
|
|||||||
val mainHeader: File get() = headersDir.resolve("$frameworkName.h")
|
val mainHeader: File get() = headersDir.resolve("$frameworkName.h")
|
||||||
}
|
}
|
||||||
|
|
||||||
data class BinaryLibrary(val libraryFile: File, val kind: Kind) : TestCompilationArtifact {
|
data class BinaryLibrary(val libraryFile: File) : TestCompilationArtifact {
|
||||||
|
|
||||||
enum class Kind {
|
|
||||||
STATIC, DYNAMIC
|
|
||||||
}
|
|
||||||
|
|
||||||
override val logFile: File get() = libraryFile.resolveSibling("${libraryFile.name}.log")
|
override val logFile: File get() = libraryFile.resolveSibling("${libraryFile.name}.log")
|
||||||
|
|
||||||
|
|||||||
+10
-9
@@ -33,7 +33,7 @@ internal class TestCompilationFactory {
|
|||||||
private data class KlibCacheKey(val sourceModules: Set<TestModule>, val freeCompilerArgs: TestCompilerArgs)
|
private data class KlibCacheKey(val sourceModules: Set<TestModule>, val freeCompilerArgs: TestCompilerArgs)
|
||||||
private data class ExecutableCacheKey(val sourceModules: Set<TestModule>)
|
private data class ExecutableCacheKey(val sourceModules: Set<TestModule>)
|
||||||
private data class ObjCFrameworkCacheKey(val sourceModules: Set<TestModule>)
|
private data class ObjCFrameworkCacheKey(val sourceModules: Set<TestModule>)
|
||||||
private data class BinaryLibraryCacheKey(val sourceModules: Set<TestModule>, val kind: BinaryLibrary.Kind)
|
private data class BinaryLibraryCacheKey(val sourceModules: Set<TestModule>, val kind: BinaryLibraryKind)
|
||||||
|
|
||||||
// A pair of compilations for a KLIB itself and for its static cache that are created together.
|
// A pair of compilations for a KLIB itself and for its static cache that are created together.
|
||||||
private data class KlibCompilations(val klib: TestCompilation<KLIB>, val staticCache: TestCompilation<KLIBStaticCache>?)
|
private data class KlibCompilations(val klib: TestCompilation<KLIB>, val staticCache: TestCompilation<KLIBStaticCache>?)
|
||||||
@@ -86,7 +86,7 @@ internal class TestCompilationFactory {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun testCaseToBinaryLibrary(testCase: TestCase, settings: Settings, kind: BinaryLibrary.Kind): BinaryLibraryCompilation {
|
fun testCaseToBinaryLibrary(testCase: TestCase, settings: Settings, kind: BinaryLibraryKind): BinaryLibraryCompilation {
|
||||||
val rootModules = testCase.rootModules
|
val rootModules = testCase.rootModules
|
||||||
val cacheKey = BinaryLibraryCacheKey(testCase.rootModules, kind)
|
val cacheKey = BinaryLibraryCacheKey(testCase.rootModules, kind)
|
||||||
cachedBinaryLibraryCompilations[cacheKey]?.let { return it }
|
cachedBinaryLibraryCompilations[cacheKey]?.let { return it }
|
||||||
@@ -97,14 +97,15 @@ internal class TestCompilationFactory {
|
|||||||
) = getDependenciesAndSourceModules(settings, testCase.rootModules, testCase.freeCompilerArgs) {
|
) = getDependenciesAndSourceModules(settings, testCase.rootModules, testCase.freeCompilerArgs) {
|
||||||
ProduceStaticCache.No
|
ProduceStaticCache.No
|
||||||
}
|
}
|
||||||
val expectedArtifact = BinaryLibrary(settings.artifactFileForBinaryLibrary(rootModules, kind), kind = kind)
|
val expectedArtifact = BinaryLibrary(settings.artifactFileForBinaryLibrary(rootModules, kind))
|
||||||
return cachedBinaryLibraryCompilations.computeIfAbsent(cacheKey) {
|
return cachedBinaryLibraryCompilations.computeIfAbsent(cacheKey) {
|
||||||
BinaryLibraryCompilation(
|
BinaryLibraryCompilation(
|
||||||
settings = settings,
|
settings = settings,
|
||||||
freeCompilerArgs = testCase.freeCompilerArgs,
|
freeCompilerArgs = testCase.freeCompilerArgs,
|
||||||
sourceModules = sourceModules,
|
sourceModules = sourceModules,
|
||||||
dependencies = dependencies,
|
dependencies = dependencies,
|
||||||
expectedArtifact = expectedArtifact
|
expectedArtifact = expectedArtifact,
|
||||||
|
kind = kind,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -330,17 +331,17 @@ internal class TestCompilationFactory {
|
|||||||
private fun Settings.artifactFileForExecutable(module: TestModule.Exclusive) =
|
private fun Settings.artifactFileForExecutable(module: TestModule.Exclusive) =
|
||||||
singleModuleArtifactFile(module, get<KotlinNativeTargets>().testTarget.family.exeSuffix)
|
singleModuleArtifactFile(module, get<KotlinNativeTargets>().testTarget.family.exeSuffix)
|
||||||
|
|
||||||
private fun Settings.pickBinaryLibrarySuffix(kind: BinaryLibrary.Kind) = when (kind) {
|
private fun Settings.pickBinaryLibrarySuffix(kind: BinaryLibraryKind) = when (kind) {
|
||||||
BinaryLibrary.Kind.STATIC -> get<KotlinNativeTargets>().testTarget.family.staticSuffix
|
BinaryLibraryKind.STATIC -> get<KotlinNativeTargets>().testTarget.family.staticSuffix
|
||||||
BinaryLibrary.Kind.DYNAMIC -> get<KotlinNativeTargets>().testTarget.family.dynamicSuffix
|
BinaryLibraryKind.DYNAMIC -> get<KotlinNativeTargets>().testTarget.family.dynamicSuffix
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Settings.artifactFileForBinaryLibrary(modules: Set<TestModule.Exclusive>, kind: BinaryLibrary.Kind) = when (modules.size) {
|
private fun Settings.artifactFileForBinaryLibrary(modules: Set<TestModule.Exclusive>, kind: BinaryLibraryKind) = when (modules.size) {
|
||||||
1 -> artifactFileForBinaryLibrary(modules.first(), kind)
|
1 -> artifactFileForBinaryLibrary(modules.first(), kind)
|
||||||
else -> multiModuleArtifactFile(modules, pickBinaryLibrarySuffix(kind))
|
else -> multiModuleArtifactFile(modules, pickBinaryLibrarySuffix(kind))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Settings.artifactFileForBinaryLibrary(module: TestModule.Exclusive, kind: BinaryLibrary.Kind) =
|
private fun Settings.artifactFileForBinaryLibrary(module: TestModule.Exclusive, kind: BinaryLibraryKind) =
|
||||||
singleModuleArtifactFile(module, pickBinaryLibrarySuffix(kind))
|
singleModuleArtifactFile(module, pickBinaryLibrarySuffix(kind))
|
||||||
|
|
||||||
private fun Settings.artifactFileForKlib(modules: Set<TestModule>, freeCompilerArgs: TestCompilerArgs): File =
|
private fun Settings.artifactFileForKlib(modules: Set<TestModule>, freeCompilerArgs: TestCompilerArgs): File =
|
||||||
|
|||||||
+4
@@ -295,3 +295,7 @@ internal enum class CompilerOutputInterceptor {
|
|||||||
DEFAULT,
|
DEFAULT,
|
||||||
NONE
|
NONE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal enum class BinaryLibraryKind {
|
||||||
|
STATIC, DYNAMIC
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user