[K2/N] Add klib contents serialization tests from old testinfra
Merge-request: KT-MR-8509 Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
This commit is contained in:
committed by
Space Team
parent
8bc2aaa295
commit
debbfa8397
+2
-2
@@ -105,7 +105,7 @@ fun main() {
|
||||
testClass<AbstractNativeKlibContentsTest>(
|
||||
suiteTestClassName = "NativeK1LibContentsTestGenerated"
|
||||
) {
|
||||
model("klibContents", pattern = "^([^_](.+)).kt$", recursive = false)
|
||||
model("klibContents", pattern = "^([^_](.+)).kt$", recursive = true)
|
||||
}
|
||||
}
|
||||
testGroup("native/native.tests/tests-gen", "native/native.tests/testData") {
|
||||
@@ -113,7 +113,7 @@ fun main() {
|
||||
suiteTestClassName = "NativeK2LibContentsTestGenerated",
|
||||
annotations = listOf(provider<K2Pipeline>())
|
||||
) {
|
||||
model("klibContents", pattern = "^([^_](.+)).kt$", recursive = false)
|
||||
model("klibContents", pattern = "^([^_](.+)).kt$", recursive = true)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
@@ -15,6 +15,7 @@ import org.jetbrains.kotlin.konan.blackboxtest.support.runner.*
|
||||
import org.jetbrains.kotlin.konan.blackboxtest.support.settings.*
|
||||
import org.jetbrains.kotlin.konan.blackboxtest.support.util.*
|
||||
import org.jetbrains.kotlin.test.services.JUnit5Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Assumptions
|
||||
import org.junit.jupiter.api.Tag
|
||||
import java.io.File
|
||||
|
||||
@@ -23,6 +24,7 @@ abstract class AbstractNativeKlibContentsTest : AbstractNativeSimpleTest() {
|
||||
|
||||
protected fun runTest(@TestDataFile testPath: String) {
|
||||
val testPathFull = getAbsoluteFile(testPath)
|
||||
muteTestIfNecessary(testPathFull)
|
||||
|
||||
val testCase: TestCase = generateTestCaseWithSingleSource(testPathFull, listOf())
|
||||
val testCompilationResult: TestCompilationResult.Success<out KLIB> = compileToLibrary(testCase)
|
||||
|
||||
+19
@@ -5,10 +5,12 @@
|
||||
|
||||
package org.jetbrains.kotlin.konan.blackboxtest
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import org.jetbrains.kotlin.konan.blackboxtest.support.PackageName
|
||||
import org.jetbrains.kotlin.konan.blackboxtest.support.TestCase
|
||||
import org.jetbrains.kotlin.konan.blackboxtest.support.TestCaseId
|
||||
import org.jetbrains.kotlin.konan.blackboxtest.support.TestCompilerArgs
|
||||
import org.jetbrains.kotlin.konan.blackboxtest.support.TestDirectives
|
||||
import org.jetbrains.kotlin.konan.blackboxtest.support.TestFile
|
||||
import org.jetbrains.kotlin.konan.blackboxtest.support.TestKind
|
||||
import org.jetbrains.kotlin.konan.blackboxtest.support.TestModule
|
||||
@@ -23,9 +25,12 @@ import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.TestCompilati
|
||||
import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.TestCompilationResult.Companion.assertSuccess
|
||||
import org.jetbrains.kotlin.konan.blackboxtest.support.runner.TestRunChecks
|
||||
import org.jetbrains.kotlin.konan.blackboxtest.support.settings.KotlinNativeTargets
|
||||
import org.jetbrains.kotlin.konan.blackboxtest.support.settings.PipelineType
|
||||
import org.jetbrains.kotlin.konan.blackboxtest.support.settings.SimpleTestDirectories
|
||||
import org.jetbrains.kotlin.konan.blackboxtest.support.settings.Timeouts
|
||||
import org.jetbrains.kotlin.konan.blackboxtest.support.util.LAUNCHER_MODULE_NAME
|
||||
import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
||||
import org.junit.jupiter.api.Assumptions
|
||||
import java.io.File
|
||||
|
||||
private val DEFAULT_EXTRAS = TestCase.WithTestRunnerExtras(TestRunnerType.DEFAULT)
|
||||
@@ -125,3 +130,17 @@ private fun getLibraryArtifact(testCase: TestCase, dir: File) =
|
||||
|
||||
private fun AbstractNativeSimpleTest.getExecutableArtifact() =
|
||||
TestCompilationArtifact.Executable(buildDir.resolve("app." + testRunSettings.get<KotlinNativeTargets>().testTarget.family.exeSuffix))
|
||||
|
||||
private fun directiveValues(testDataFileContents: String, directive: String) =
|
||||
InTextDirectivesUtils.findListWithPrefixes(testDataFileContents, "// $directive: ")
|
||||
|
||||
internal fun AbstractNativeSimpleTest.muteTestIfNecessary(testDataFile: File) = muteTestIfNecessary(FileUtil.loadFile(testDataFile))
|
||||
internal fun AbstractNativeSimpleTest.muteTestIfNecessary(testDataFileContents: String) {
|
||||
val pipelineType = testRunSettings.get<PipelineType>()
|
||||
val mutedWhenValues = directiveValues(testDataFileContents, TestDirectives.MUTED_WHEN.name)
|
||||
Assumptions.assumeFalse(mutedWhenValues.any { it == pipelineType.mutedOption.name })
|
||||
}
|
||||
|
||||
internal fun AbstractNativeSimpleTest.freeCompilerArgs(testDataFile: File) = freeCompilerArgs(FileUtil.loadFile(testDataFile))
|
||||
internal fun AbstractNativeSimpleTest.freeCompilerArgs(testDataFileContents: String) =
|
||||
directiveValues(testDataFileContents, TestDirectives.FREE_COMPILER_ARGS.name)
|
||||
|
||||
+12
@@ -133,6 +133,13 @@ internal object TestDirectives : SimpleDirectivesContainer() {
|
||||
Specify a filename containing the LLDB commands and the patterns that
|
||||
the output should match""".trimIndent(),
|
||||
)
|
||||
|
||||
// TODO "MUTED_WHEN" directive should be supported not only in AbstractNativeSimpleTest, but also in other hierarchies
|
||||
val MUTED_WHEN by enumDirective<MutedOption>(
|
||||
description = """
|
||||
Usage: // MUTED_WHEN: [K1, K2]
|
||||
In native simple tests, specify the pipeline types to mute the test""".trimIndent(),
|
||||
)
|
||||
}
|
||||
|
||||
internal enum class TestKind {
|
||||
@@ -148,6 +155,11 @@ internal enum class TestRunnerType {
|
||||
NO_EXIT
|
||||
}
|
||||
|
||||
internal enum class MutedOption {
|
||||
K1,
|
||||
K2
|
||||
}
|
||||
|
||||
internal class TestCompilerArgs(val compilerArgs: List<String>) {
|
||||
private val uniqueCompilerArgs = compilerArgs.toSet()
|
||||
override fun hashCode() = uniqueCompilerArgs.hashCode()
|
||||
|
||||
+4
-3
@@ -5,6 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.konan.blackboxtest.support.settings
|
||||
|
||||
import org.jetbrains.kotlin.konan.blackboxtest.support.MutedOption
|
||||
import org.jetbrains.kotlin.konan.blackboxtest.support.TestKind
|
||||
import org.jetbrains.kotlin.konan.blackboxtest.support.runner.LocalTestRunner
|
||||
import org.jetbrains.kotlin.konan.blackboxtest.support.runner.NoopTestRunner
|
||||
@@ -239,9 +240,9 @@ internal sealed interface CacheMode {
|
||||
}
|
||||
}
|
||||
|
||||
internal enum class PipelineType(val compilerFlags: List<String>) {
|
||||
K1(emptyList()),
|
||||
K2(listOf("-language-version", "2.0"));
|
||||
internal enum class PipelineType(val mutedOption: MutedOption, val compilerFlags: List<String>) {
|
||||
K1(MutedOption.K1, emptyList()),
|
||||
K2(MutedOption.K2, listOf("-language-version", "2.0"));
|
||||
|
||||
override fun toString() = if (compilerFlags.isEmpty()) "" else compilerFlags.joinToString(prefix = "(", postfix = ")", separator = " ")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user