[K/N][KT-39120] Build platform libraries with -fmodules
Merge-request: KT-MR-8175 Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
This commit is contained in:
committed by
Space Team
parent
d85b23ebb9
commit
45de88abae
-1
@@ -13,7 +13,6 @@ import org.jetbrains.kotlin.konan.blackboxtest.support.settings.*
|
||||
import java.io.File
|
||||
|
||||
abstract class AbstractNativeCInteropBaseTest : AbstractNativeSimpleTest() {
|
||||
private val buildDir: File get() = testRunSettings.get<SimpleTestDirectories>().testBuildDir
|
||||
internal val targets: KotlinNativeTargets get() = testRunSettings.get<KotlinNativeTargets>()
|
||||
internal val kotlinNativeClassLoader: KotlinNativeClassLoader get() = testRunSettings.get<KotlinNativeClassLoader>()
|
||||
|
||||
|
||||
+38
@@ -17,6 +17,7 @@ import org.junit.jupiter.api.Tag
|
||||
import org.jetbrains.kotlin.konan.blackboxtest.support.runner.*
|
||||
import org.jetbrains.kotlin.test.services.JUnit5Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Assumptions
|
||||
import kotlin.test.assertIs
|
||||
|
||||
@Tag("cinterop")
|
||||
abstract class AbstractNativeCInteropKT39120Test : AbstractNativeCInteropBaseTest() {
|
||||
@@ -51,10 +52,47 @@ abstract class AbstractNativeCInteropKT39120Test : AbstractNativeCInteropBaseTes
|
||||
val expectedFiltered2Output = golden2File.readText()
|
||||
val actualFiltered2Output = filterContentsOutput(contents2, " pod.Version|POD|class Pod")
|
||||
assertEquals(StringUtilRt.convertLineSeparators(expectedFiltered2Output), StringUtilRt.convertLineSeparators(actualFiltered2Output))
|
||||
|
||||
val ktFile = testPathFull.resolve(DEFAULT_FILE_NAME)
|
||||
if (ktFile.exists()) {
|
||||
// Just compile "main.kt" with klib1 and klib2, without running resulting executable
|
||||
val module = TestModule.Exclusive(DEFAULT_MODULE_NAME, emptySet(), emptySet()).apply {
|
||||
files += TestFile.createCommitted(ktFile, this)
|
||||
}
|
||||
val compilationResult = compileToExecutable(
|
||||
createTestCaseNoTestRun(module, TestCompilerArgs(listOf())),
|
||||
klib1.asLibraryDependency(),
|
||||
klib2.asLibraryDependency()
|
||||
)
|
||||
|
||||
val expectedFailureTxtFile = testPathFull.resolve("expected.compilation.failure.txt")
|
||||
if (expectedFailureTxtFile.exists()) {
|
||||
assertIs<TestCompilationResult.CompilationToolFailure>(compilationResult)
|
||||
val expectedFailureSubstring = expectedFailureTxtFile.readText()
|
||||
val actualFailure = compilationResult.loggedData.toString()
|
||||
assert(actualFailure.contains(expectedFailureSubstring)) {
|
||||
"Expected failure substring:\n$expectedFailureSubstring\nActual failure logged data:\n$actualFailure"
|
||||
}
|
||||
} else {
|
||||
compilationResult.assertSuccess()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun filterContentsOutput(contents: String, pattern: String) =
|
||||
contents.split("\n").filter {
|
||||
it.contains(Regex(pattern))
|
||||
}.joinToString(separator = "\n")
|
||||
|
||||
private fun createTestCaseNoTestRun(module: TestModule.Exclusive, compilerArgs: TestCompilerArgs) = TestCase(
|
||||
id = TestCaseId.Named(module.name),
|
||||
kind = TestKind.STANDALONE_NO_TR,
|
||||
modules = setOf(module),
|
||||
freeCompilerArgs = compilerArgs,
|
||||
nominalPackageName = PackageName.EMPTY,
|
||||
checks = TestRunChecks.Default(testRunSettings.get<Timeouts>().executionTimeout),
|
||||
extras = TestCase.NoTestRunnerExtras(".${module.name}")
|
||||
).apply {
|
||||
initialize(null, null)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -10,6 +10,7 @@ import org.jetbrains.kotlin.konan.blackboxtest.CachesAutoBuildTest.Companion.TES
|
||||
import org.jetbrains.kotlin.konan.blackboxtest.support.EnforcedHostTarget
|
||||
import org.jetbrains.kotlin.konan.blackboxtest.support.TestCompilerArgs
|
||||
import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.TestCompilationArtifact.KLIB
|
||||
import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.TestCompilationResult.Companion.assertSuccess
|
||||
import org.jetbrains.kotlin.konan.blackboxtest.support.settings.CacheMode
|
||||
import org.jetbrains.kotlin.konan.blackboxtest.support.settings.KotlinNativeTargets
|
||||
import org.jetbrains.kotlin.konan.blackboxtest.support.settings.OptimizationMode
|
||||
@@ -59,7 +60,7 @@ class CachesAutoBuildTest : AbstractNativeSimpleTest() {
|
||||
)
|
||||
),
|
||||
*dependencies
|
||||
)
|
||||
).assertSuccess().resultingArtifact
|
||||
|
||||
private val autoCacheDir: File get() = buildDir.resolve("__auto_cache__")
|
||||
private val cacheFlavor: String
|
||||
|
||||
+18
-18
@@ -13,6 +13,8 @@ import org.jetbrains.kotlin.konan.blackboxtest.support.EnforcedHostTarget
|
||||
import org.jetbrains.kotlin.konan.blackboxtest.support.TestCase
|
||||
import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.TestCompilationArtifact.Executable
|
||||
import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.TestCompilationArtifact.KLIB
|
||||
import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.TestCompilationResult
|
||||
import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.TestCompilationResult.Companion.assertSuccess
|
||||
import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.TestCompilationResult.Success
|
||||
import org.jetbrains.kotlin.konan.blackboxtest.support.runner.TestExecutable
|
||||
import org.jetbrains.kotlin.konan.blackboxtest.support.runner.TestRunners
|
||||
@@ -49,25 +51,23 @@ class InfrastructureDumpedTestListingTest : AbstractNativeSimpleTest() {
|
||||
|
||||
val barTestCase: TestCase = generateTestCaseWithSingleModule(rootDir.resolve("bar"))
|
||||
|
||||
val executableTestCase: TestCase
|
||||
val executableCompilationResult: Success<out Executable>
|
||||
val (executableTestCase: TestCase, executableCompilationResult: TestCompilationResult<out Executable>) =
|
||||
if (fromSources) {
|
||||
barTestCase to compileToExecutable(barTestCase, fooLibrary.asLibraryDependency())
|
||||
} else {
|
||||
val barCompilationResult: Success<out KLIB> = compileToLibrary(barTestCase, fooLibrary.asLibraryDependency())
|
||||
val barLibrary: KLIB = barCompilationResult.resultingArtifact
|
||||
|
||||
if (fromSources) {
|
||||
executableTestCase = barTestCase
|
||||
executableCompilationResult = compileToExecutable(barTestCase, fooLibrary.asLibraryDependency())
|
||||
} else {
|
||||
val barCompilationResult: Success<out KLIB> = compileToLibrary(barTestCase, fooLibrary.asLibraryDependency())
|
||||
val barLibrary: KLIB = barCompilationResult.resultingArtifact
|
||||
val executableTestCase = generateTestCaseWithSingleModule(moduleDir = null) // No sources.
|
||||
executableTestCase to compileToExecutable(
|
||||
executableTestCase,
|
||||
fooLibrary.asLibraryDependency(),
|
||||
barLibrary.asIncludedLibraryDependency()
|
||||
)
|
||||
}
|
||||
|
||||
executableTestCase = generateTestCaseWithSingleModule(moduleDir = null) // No sources.
|
||||
executableCompilationResult = compileToExecutable(
|
||||
executableTestCase,
|
||||
fooLibrary.asLibraryDependency(),
|
||||
barLibrary.asIncludedLibraryDependency()
|
||||
)
|
||||
}
|
||||
|
||||
val executable: Executable = executableCompilationResult.resultingArtifact
|
||||
val executableCompilationSuccess = executableCompilationResult.assertSuccess()
|
||||
val executable: Executable = executableCompilationSuccess.resultingArtifact
|
||||
|
||||
// check that the test listing dumped during the compilation matches our expectations:
|
||||
val testDumpFile = executable.testDumpFile
|
||||
@@ -78,7 +78,7 @@ class InfrastructureDumpedTestListingTest : AbstractNativeSimpleTest() {
|
||||
assertTrue(dumpedTestListing.isNotEmpty())
|
||||
|
||||
// parse test listing obtained from executable file with the help of --ktest_list_tests flag:
|
||||
val testExecutable = TestExecutable.fromCompilationResult(executableTestCase, executableCompilationResult)
|
||||
val testExecutable = TestExecutable.fromCompilationResult(executableTestCase, executableCompilationSuccess)
|
||||
val extractedTestListing = TestRunners.extractTestNames(testExecutable, testRunSettings).toSet()
|
||||
|
||||
assertEquals(extractedTestListing, dumpedTestListing)
|
||||
|
||||
+4
-5
@@ -58,10 +58,9 @@ internal fun AbstractNativeSimpleTest.compileToExecutable(
|
||||
sourcesDir: File,
|
||||
freeCompilerArgs: TestCompilerArgs,
|
||||
vararg dependencies: TestCompilationArtifact.KLIB
|
||||
): TestCompilationArtifact.Executable {
|
||||
): TestCompilationResult<out TestCompilationArtifact.Executable> {
|
||||
val testCase: TestCase = generateTestCaseWithSingleModule(sourcesDir, freeCompilerArgs)
|
||||
val compilationResult = compileToExecutable(testCase, dependencies.map { it.asLibraryDependency() })
|
||||
return compilationResult.resultingArtifact
|
||||
return compileToExecutable(testCase, dependencies.map { it.asLibraryDependency() })
|
||||
}
|
||||
|
||||
internal fun AbstractNativeSimpleTest.compileToExecutable(testCase: TestCase, vararg dependencies: TestCompilationDependency<*>) =
|
||||
@@ -109,7 +108,7 @@ private fun AbstractNativeSimpleTest.compileToLibrary(
|
||||
private fun AbstractNativeSimpleTest.compileToExecutable(
|
||||
testCase: TestCase,
|
||||
dependencies: List<TestCompilationDependency<*>>
|
||||
): TestCompilationResult.Success<out TestCompilationArtifact.Executable> {
|
||||
): TestCompilationResult<out TestCompilationArtifact.Executable> {
|
||||
val compilation = ExecutableCompilation(
|
||||
settings = testRunSettings,
|
||||
freeCompilerArgs = testCase.freeCompilerArgs,
|
||||
@@ -118,7 +117,7 @@ private fun AbstractNativeSimpleTest.compileToExecutable(
|
||||
dependencies = dependencies,
|
||||
expectedArtifact = getExecutableArtifact()
|
||||
)
|
||||
return compilation.result.assertSuccess()
|
||||
return compilation.result
|
||||
}
|
||||
|
||||
private fun getLibraryArtifact(testCase: TestCase, dir: File) =
|
||||
|
||||
Reference in New Issue
Block a user