[Native][tests] Pass "free compiler args" to static cache compilations

^KT-50775
This commit is contained in:
Dmitriy Dolovov
2022-01-25 13:12:20 +03:00
parent 33a09fbb77
commit 02d74fbd87
3 changed files with 9 additions and 5 deletions
@@ -76,7 +76,7 @@ abstract class AbstractNativeKlibABITest : AbstractNativeSimpleTest() {
text = generateBoxFunctionLauncher("box")
)
val testCase = createTestCase(module, COMPILER_ARGS_FOR_EXECUTABLE)
val testCase = createTestCase(module, COMPILER_ARGS_FOR_STATIC_CACHE_AND_EXECUTABLE)
val compilation = ExecutableCompilation(
settings = testRunSettings,
@@ -96,6 +96,7 @@ abstract class AbstractNativeKlibABITest : AbstractNativeSimpleTest() {
private fun buildCacheForKlib(moduleDependencies: Collection<File>, klibArtifact: KLIB) {
val compilation = StaticCacheCompilation(
settings = testRunSettings,
freeCompilerArgs = COMPILER_ARGS_FOR_STATIC_CACHE_AND_EXECUTABLE,
dependencies = createLibraryCacheDependencies(moduleDependencies) + klibArtifact.toDependency(),
expectedArtifact = klibArtifact.toStaticCacheArtifact()
)
@@ -145,7 +146,7 @@ abstract class AbstractNativeKlibABITest : AbstractNativeSimpleTest() {
listOf("-nostdlib") // stdlib is passed explicitly.
)
private val COMPILER_ARGS_FOR_EXECUTABLE = TestCompilerArgs(
private val COMPILER_ARGS_FOR_STATIC_CACHE_AND_EXECUTABLE = TestCompilerArgs(
COMPILER_ARGS_FOR_KLIB.compilerArgs + "-Xpartial-linkage"
)
@@ -28,11 +28,11 @@ internal abstract class BasicCompilation<A : TestCompilationArtifact>(
protected val home: KotlinNativeHome,
private val classLoader: KotlinNativeClassLoader,
private val optimizationMode: OptimizationMode,
protected val freeCompilerArgs: TestCompilerArgs,
protected val dependencies: Iterable<TestCompilationDependency<*>>,
protected val expectedArtifact: A
) : TestCompilation<A>() {
protected abstract val sourceModules: Collection<TestModule>
protected abstract val freeCompilerArgs: TestCompilerArgs
// Runs the compiler and memorizes the result on property access.
final override val result: TestCompilationResult<out A> by lazy {
@@ -143,7 +143,7 @@ internal abstract class SourceBasedCompilation<A : TestCompilationArtifact>(
private val memoryModel: MemoryModel,
private val threadStateChecker: ThreadStateChecker,
private val gcType: GCType,
override val freeCompilerArgs: TestCompilerArgs,
freeCompilerArgs: TestCompilerArgs,
override val sourceModules: Collection<TestModule>,
dependencies: Iterable<TestCompilationDependency<*>>,
expectedArtifact: A
@@ -152,6 +152,7 @@ internal abstract class SourceBasedCompilation<A : TestCompilationArtifact>(
home = home,
classLoader = classLoader,
optimizationMode = optimizationMode,
freeCompilerArgs = freeCompilerArgs,
dependencies = dependencies,
expectedArtifact = expectedArtifact
) {
@@ -255,6 +256,7 @@ internal class ExecutableCompilation(
internal class StaticCacheCompilation(
settings: Settings,
freeCompilerArgs: TestCompilerArgs,
dependencies: Iterable<TestCompilationDependency<*>>,
expectedArtifact: KLIBStaticCache
) : BasicCompilation<KLIBStaticCache>(
@@ -262,11 +264,11 @@ internal class StaticCacheCompilation(
home = settings.get(),
classLoader = settings.get(),
optimizationMode = settings.get(),
freeCompilerArgs = freeCompilerArgs,
dependencies = dependencies,
expectedArtifact = expectedArtifact
) {
override val sourceModules get() = emptyList<TestModule>()
override val freeCompilerArgs get() = TestCompilerArgs.EMPTY
private val cacheRootDir: File = run {
val cacheKind = settings.get<CacheKind>()
@@ -94,6 +94,7 @@ internal class TestCompilationFactory {
val staticCacheCompilation: StaticCacheCompilation? = if (staticCacheArtifact != null) {
StaticCacheCompilation(
settings = settings,
freeCompilerArgs = freeCompilerArgs,
dependencies = dependencies.staticCacheDependenciesWith(klibCompilation.asKlibDependency(type = /* does not matter in fact*/ Library)),
expectedArtifact = staticCacheArtifact
)