[K/N][Tests] Migrate test ir_providers_mismatch
^KT-61259
This commit is contained in:
committed by
Space Team
parent
88fbaed22e
commit
20f6b0cb0c
@@ -1611,52 +1611,6 @@ dynamicTest("interop_kotlin_exception_hook") {
|
||||
outputChecker = { s -> s.contains("OK. Kotlin unhandled exception hook") }
|
||||
}
|
||||
|
||||
standaloneTest("library_ir_provider_mismatch") {
|
||||
enabled = !isAggressiveGC // No need to test with different GC schedulers
|
||||
|
||||
String librarySource = "$projectDir/link/ir_providers/library/empty.kt"
|
||||
String invalidManifest = "$projectDir/link/ir_providers/library/manifest.properties"
|
||||
String mainSource = "$projectDir/link/ir_providers/hello.kt"
|
||||
|
||||
File outputDir = project.layout.buildDirectory.dir(name).get().asFile
|
||||
String currentTarget = project.target.name
|
||||
|
||||
inputs.files(librarySource, invalidManifest)
|
||||
inputs.property("target", currentTarget)
|
||||
outputs.dir(outputDir)
|
||||
source = mainSource
|
||||
|
||||
doBeforeBuild {
|
||||
konanc("$librarySource -target $currentTarget -p library -o $outputDir/unsupported_ir_provider/empty.klib -manifest $invalidManifest")
|
||||
konanc("$librarySource -target $currentTarget -p library -o $outputDir/supported_ir_provider/empty.klib ")
|
||||
|
||||
// Should not be successful:
|
||||
boolean failed = false
|
||||
String command = "$mainSource -target $currentTarget -p program -o $outputDir/failed.kexe -l $outputDir/unsupported_ir_provider/empty.klib"
|
||||
try {
|
||||
konanc(command)
|
||||
} catch (Throwable t) {
|
||||
String exceptionText = t.message
|
||||
exceptionText = PlatformInfo.isWindows() ? exceptionText.replace("\\", "/") : exceptionText
|
||||
|
||||
String expectedText = "warning: KLIB resolver: Skipping '$outputDir/unsupported_ir_provider/empty.klib'. The library requires unknown IR provider: UNSUPPORTED"
|
||||
expectedText = PlatformInfo.isWindows() ? expectedText.replace("\\", "/") : expectedText
|
||||
|
||||
if (t instanceof GradleException && exceptionText.contains(expectedText)) {
|
||||
failed = true
|
||||
} else {
|
||||
throw t
|
||||
}
|
||||
}
|
||||
|
||||
if (!failed) {
|
||||
throw new GradleException("Kotlin/Natice invocation is successful but should fail:\n$command")
|
||||
}
|
||||
}
|
||||
|
||||
flags = ["-l", "$outputDir/supported_ir_provider/empty.klib"]
|
||||
}
|
||||
|
||||
standaloneTest("kt51302") {
|
||||
enabled = project.target.name == project.hostName
|
||||
source = "serialization/KT-51302/main.kt"
|
||||
|
||||
+50
@@ -5,10 +5,15 @@
|
||||
|
||||
package org.jetbrains.kotlin.konan.test.blackbox
|
||||
|
||||
import org.jetbrains.kotlin.konan.test.blackbox.support.TestCase
|
||||
import org.jetbrains.kotlin.konan.test.blackbox.support.TestCompilerArgs
|
||||
import org.jetbrains.kotlin.konan.test.blackbox.support.TestKind
|
||||
import org.jetbrains.kotlin.konan.test.blackbox.support.TestName
|
||||
import org.jetbrains.kotlin.konan.test.blackbox.support.compilation.CompilationToolException
|
||||
import org.jetbrains.kotlin.konan.test.blackbox.support.compilation.LibraryCompilation
|
||||
import org.jetbrains.kotlin.konan.test.blackbox.support.compilation.TestCompilationArtifact.KLIB
|
||||
import org.jetbrains.kotlin.konan.test.blackbox.support.compilation.TestCompilationResult.Companion.assertSuccess
|
||||
import org.jetbrains.kotlin.konan.test.blackbox.support.runner.TestExecutable
|
||||
import org.jetbrains.kotlin.library.SearchPathResolver
|
||||
import org.junit.jupiter.api.DisplayName
|
||||
import org.junit.jupiter.api.Tag
|
||||
@@ -63,6 +68,50 @@ class KlibResolverTest : AbstractNativeSimpleTest() {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIrProvidersMatch() {
|
||||
testIrProvidersMismatchImpl(irProvidersMismatchSrcDir, TestCompilerArgs.EMPTY)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIrProvidersMismatch() {
|
||||
val freeCompilerArgs = TestCompilerArgs(listOf(
|
||||
"-manifest",
|
||||
irProvidersMismatchSrcDir.resolve("manifest.properties").absolutePath
|
||||
))
|
||||
try {
|
||||
testIrProvidersMismatchImpl(irProvidersMismatchSrcDir, freeCompilerArgs)
|
||||
} catch (cte: CompilationToolException) {
|
||||
if (!cte.reason.contains("The library requires unknown IR provider: UNSUPPORTED"))
|
||||
throw cte
|
||||
}
|
||||
}
|
||||
|
||||
private fun testIrProvidersMismatchImpl(srcDir: File, freeCompilerArgs: TestCompilerArgs) {
|
||||
val testCaseKlib = generateTestCaseWithSingleModule(srcDir.resolve("empty.kt"), freeCompilerArgs)
|
||||
val klibResult = LibraryCompilation(
|
||||
settings = testRunSettings,
|
||||
freeCompilerArgs = testCaseKlib.freeCompilerArgs,
|
||||
sourceModules = testCaseKlib.modules,
|
||||
dependencies = listOf(),
|
||||
expectedArtifact = getLibraryArtifact(testCaseKlib, buildDir)
|
||||
).result.assertSuccess()
|
||||
|
||||
val testCase = generateTestCaseWithSingleFile(
|
||||
sourceFile = srcDir.resolve("irProvidersMismatch.kt"),
|
||||
testKind = TestKind.STANDALONE_NO_TR,
|
||||
extras = TestCase.NoTestRunnerExtras("main"),
|
||||
)
|
||||
val executableResult =
|
||||
compileToExecutable(testCase, klibResult.resultingArtifact.asLibraryDependency()).assertSuccess()
|
||||
val testExecutable = TestExecutable(
|
||||
executableResult.resultingArtifact,
|
||||
executableResult.loggedData,
|
||||
listOf(TestName("testIrProvidersMismatch"))
|
||||
)
|
||||
runExecutableAndVerify(testCase, testExecutable)
|
||||
}
|
||||
|
||||
private fun createModules(vararg modules: Module): List<Module> {
|
||||
val mapping: Map<String, Module> = modules.groupBy(Module::name).mapValues {
|
||||
it.value.singleOrNull() ?: error("Duplicated modules: ${it.value}")
|
||||
@@ -152,5 +201,6 @@ class KlibResolverTest : AbstractNativeSimpleTest() {
|
||||
|
||||
companion object {
|
||||
private const val USER_DIR = "user.dir"
|
||||
private val irProvidersMismatchSrcDir = File("native/native.tests/testData/irProvidersMismatch")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user