[K/N][tests] Migrate various runtime/ tests ^KT-61259

This commit is contained in:
Alexander Shabalin
2024-03-11 22:48:50 +01:00
committed by Space Team
parent 7ad4e58a7a
commit d88092aa94
99 changed files with 2102 additions and 1905 deletions
@@ -531,6 +531,7 @@ fun main() {
testClass<AbstractNativeBlackBoxTest>(
suiteTestClassName = "NativeStressTestGenerated",
annotations = listOf(
*stress(),
provider<UseStandardTestCaseGroupProvider>(),
)
) {
@@ -539,6 +540,7 @@ fun main() {
testClass<AbstractNativeBlackBoxTest>(
suiteTestClassName = "FirNativeStressTestGenerated",
annotations = listOf(
*stress(),
provider<UseStandardTestCaseGroupProvider>(),
*frontendFir(),
)
@@ -546,6 +548,28 @@ fun main() {
model("")
}
}
// GC tests
testGroup("native/native.tests/tests-gen", "native/native.tests/testData") {
testClass<AbstractNativeBlackBoxTest>(
suiteTestClassName = "NativeGCTestGenerated",
annotations = listOf(
*gc(),
provider<UseStandardTestCaseGroupProvider>(),
)
) {
model("gc")
}
testClass<AbstractNativeBlackBoxTest>(
suiteTestClassName = "FirNativeGCTestGenerated",
annotations = listOf(
*gc(),
provider<UseStandardTestCaseGroupProvider>(),
*frontendFir(),
)
) {
model("gc")
}
}
}
}
@@ -608,3 +632,14 @@ private fun cinterfaceMode(mode: String = "V1") = annotation(
"property" to ClassLevelProperty.C_INTERFACE_MODE,
"propertyValue" to mode
)
private fun gc() = arrayOf(
annotation(Tag::class.java, "gc"),
)
private fun stress() = arrayOf(
annotation(Tag::class.java, "stress"),
annotation(
EnforcedProperty::class.java,
"property" to ClassLevelProperty.EXECUTION_TIMEOUT,
"propertyValue" to "5m"
)
)
@@ -9,16 +9,15 @@ import com.intellij.testFramework.TestDataPath
import org.jetbrains.kotlin.cli.AbstractCliTest
import org.jetbrains.kotlin.cli.common.ExitCode
import org.jetbrains.kotlin.config.LanguageVersion
import org.jetbrains.kotlin.konan.test.blackbox.support.*
import org.jetbrains.kotlin.konan.test.blackbox.support.ClassLevelProperty
import org.jetbrains.kotlin.konan.test.blackbox.support.EnforcedProperty
import org.jetbrains.kotlin.konan.test.blackbox.support.LoggedData
import org.jetbrains.kotlin.konan.test.blackbox.support.TestCompilerArgs
import org.jetbrains.kotlin.konan.test.blackbox.support.compilation.*
import org.jetbrains.kotlin.konan.test.blackbox.support.compilation.LibraryCompilation
import org.jetbrains.kotlin.konan.test.blackbox.support.compilation.ObjCFrameworkCompilation
import org.jetbrains.kotlin.konan.test.blackbox.support.compilation.TestCompilationArtifact
import org.jetbrains.kotlin.konan.test.blackbox.support.compilation.TestCompilationResult
import org.jetbrains.kotlin.konan.test.blackbox.support.compilation.TestCompilationResult.Companion.assertSuccess
import org.jetbrains.kotlin.konan.test.blackbox.support.group.FirPipeline
import org.jetbrains.kotlin.konan.test.blackbox.support.settings.CacheMode
import org.jetbrains.kotlin.konan.test.blackbox.support.settings.PipelineType
import org.jetbrains.kotlin.konan.test.blackbox.support.settings.Settings
import org.jetbrains.kotlin.test.KotlinTestUtils
@@ -162,6 +161,57 @@ abstract class CompilerOutputTestBase : AbstractNativeSimpleTest() {
dir
)
}
@Test
fun testLoggingWarningWithDistCache() {
val rootDir = File("native/native.tests/testData/compilerOutput/runtimeLogging")
val testCase = generateTestCaseWithSingleFile(
rootDir.resolve("main.kt"),
freeCompilerArgs = TestCompilerArgs("-Xruntime-logs=gc=info"),
extras = TestCase.NoTestRunnerExtras("main"),
testKind = TestKind.STANDALONE_NO_TR,
)
val expectedArtifact = TestCompilationArtifact.Executable(buildDir.resolve("logging_warning_with_cache"))
val compilation = ExecutableCompilation(
testRunSettings,
freeCompilerArgs = testCase.freeCompilerArgs,
sourceModules = testCase.modules,
extras = testCase.extras,
dependencies = emptyList(),
expectedArtifact = expectedArtifact,
)
val compilationResult = compilation.result
val goldenData = rootDir.resolve(
if (testRunSettings.get<CacheMode>().useStaticCacheForDistributionLibraries) "logging_cache_warning.txt" else "empty.txt"
)
KotlinTestUtils.assertEqualsToFile(goldenData, compilationResult.toOutput())
}
@Test
fun testLoggingInvalid() {
Assumptions.assumeFalse(testRunSettings.get<CacheMode>().useStaticCacheForDistributionLibraries)
val rootDir = File("native/native.tests/testData/compilerOutput/runtimeLogging")
val testCase = generateTestCaseWithSingleFile(
rootDir.resolve("main.kt"),
freeCompilerArgs = TestCompilerArgs("-Xruntime-logs=invalid=unknown,logging=debug"),
extras = TestCase.NoTestRunnerExtras("main"),
testKind = TestKind.STANDALONE_NO_TR,
)
val expectedArtifact = TestCompilationArtifact.Executable(buildDir.resolve("logging_invalid"))
val compilation = ExecutableCompilation(
testRunSettings,
freeCompilerArgs = testCase.freeCompilerArgs,
sourceModules = testCase.modules,
extras = testCase.extras,
dependencies = emptyList(),
expectedArtifact = expectedArtifact,
)
val compilationResult = compilation.result
val goldenData = rootDir.resolve("logging_invalid_error.txt")
KotlinTestUtils.assertEqualsToFile(goldenData, compilationResult.toOutput())
}
}
@Suppress("JUnitTestCaseWithNoTests")
@@ -448,11 +448,12 @@ internal fun parseProgramArguments(registeredDirectives: RegisteredDirectives):
internal fun parseOutputRegex(registeredDirectives: RegisteredDirectives): TestRunCheck.OutputMatcher? {
if (OUTPUT_REGEX !in registeredDirectives)
return null
val regexStr = registeredDirectives.singleValue(OUTPUT_REGEX)
val regex = regexStr.toRegex(RegexOption.DOT_MATCHES_ALL)
val regexes = registeredDirectives[OUTPUT_REGEX].map { it.toRegex(RegexOption.DOT_MATCHES_ALL) }
return TestRunCheck.OutputMatcher {
assertTrue(regex.matches(it)) {
"Regex `$regex` failed to match `$it`"
regexes.forEach { regex ->
assertTrue(regex.matches(it)) {
"Regex `$regex` failed to match `$it`"
}
}
true
}