[K/N][tests] Move driver tests into their own project ^KT-61259
This commit is contained in:
committed by
Space Team
parent
316614bc9e
commit
8c6966765b
@@ -1,179 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.konan.test
|
||||
|
||||
import com.intellij.testFramework.TestDataPath
|
||||
import org.jetbrains.kotlin.konan.target.HostManager
|
||||
import org.jetbrains.kotlin.konan.test.blackbox.AbstractNativeSimpleTest
|
||||
import org.jetbrains.kotlin.konan.test.blackbox.support.NativeSimpleTestSupport
|
||||
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.TestModule
|
||||
import org.jetbrains.kotlin.konan.test.blackbox.support.compilation.ExecutableCompilation
|
||||
import org.jetbrains.kotlin.konan.test.blackbox.support.compilation.TestCompilationArtifact
|
||||
import org.jetbrains.kotlin.konan.test.blackbox.support.settings.*
|
||||
import org.jetbrains.kotlin.konan.test.blackbox.support.settings.Binaries
|
||||
import org.jetbrains.kotlin.konan.test.blackbox.support.settings.CacheMode
|
||||
import org.jetbrains.kotlin.konan.test.blackbox.support.settings.GCScheduler
|
||||
import org.jetbrains.kotlin.konan.test.blackbox.support.settings.KotlinNativeHome
|
||||
import org.jetbrains.kotlin.konan.test.blackbox.support.settings.executor
|
||||
import org.jetbrains.kotlin.konan.test.blackbox.targets
|
||||
import org.jetbrains.kotlin.native.executors.RunProcessResult
|
||||
import org.jetbrains.kotlin.native.executors.runProcess
|
||||
import org.junit.jupiter.api.Assumptions
|
||||
import org.junit.jupiter.api.Tag
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.extension.ExtendWith
|
||||
import java.io.File
|
||||
import kotlin.test.assertFalse
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertTrue
|
||||
import kotlin.time.Duration
|
||||
|
||||
@Tag("driver")
|
||||
@TestDataPath("\$PROJECT_ROOT")
|
||||
@ExtendWith(NativeSimpleTestSupport::class)
|
||||
class KonanDriverTest : AbstractNativeSimpleTest() {
|
||||
private val konanHome get() = testRunSettings.get<KotlinNativeHome>().dir
|
||||
private val buildDir get() = testRunSettings.get<Binaries>().testBinariesDir
|
||||
private val konanc get() = konanHome.resolve("bin").resolve(if (HostManager.hostIsMingw) "konanc.bat" else "konanc")
|
||||
|
||||
private val testSuiteDir = File("native/native.tests/testData/driver")
|
||||
private val source = testSuiteDir.resolve("driver0.kt")
|
||||
|
||||
@Test
|
||||
fun testLLVMVariantDev() {
|
||||
// On macOS for apple targets, clang++ from Xcode is used, which is not switchable as `dev/user`,
|
||||
// so the test cannot detect LLVM variant for apple targets on macOS host.
|
||||
Assumptions.assumeFalse(targets.hostTarget.family.isAppleFamily && targets.testTarget.family.isAppleFamily)
|
||||
// No need to test with different GC schedulers
|
||||
Assumptions.assumeFalse(testRunSettings.get<GCScheduler>() == GCScheduler.AGGRESSIVE)
|
||||
|
||||
compileSimpleFile(listOf("-Xllvm-variant=dev", "-Xverbose-phases=ObjectFiles")).let {
|
||||
assertFalse(
|
||||
it.stdout.contains("-essentials"),
|
||||
"`-essentials` must not be in stdout of dev LLVM.\nSTDOUT: ${it.stdout}\nSTDERR: ${it.stderr}\n---"
|
||||
)
|
||||
}
|
||||
compileSimpleFile(listOf("-Xllvm-variant=user", "-Xverbose-phases=ObjectFiles")).let {
|
||||
assertTrue(
|
||||
it.stdout.contains("-essentials"),
|
||||
"`-essentials` must be in stdout of user LLVM.\nSTDOUT: ${it.stdout}\nSTDERR: ${it.stderr}\n---"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun compileSimpleFile(flags: List<String>): RunProcessResult {
|
||||
val kexe = buildDir.resolve("kexe.kexe").also { it.delete() }
|
||||
val args = mutableListOf("-output", kexe.absolutePath).apply {
|
||||
add("-target")
|
||||
add(targets.testTarget.visibleName)
|
||||
addAll(flags)
|
||||
|
||||
add("-Xpartial-linkage=enable")
|
||||
add("-Xpartial-linkage-loglevel=error")
|
||||
}
|
||||
|
||||
val compilationResult = runProcess(konanc.absolutePath, source.absolutePath, *args.toTypedArray<String>()) {
|
||||
timeout = Duration.parse("5m")
|
||||
}
|
||||
testRunSettings.executor.runProcess(kexe.absolutePath) // run generated executable just to check its sanity
|
||||
return compilationResult
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDriverProducesRunnableBinaries() {
|
||||
Assumptions.assumeFalse(HostManager.hostIsMingw &&
|
||||
testRunSettings.get<CacheMode>() == CacheMode.WithoutCache &&
|
||||
testRunSettings.get<OptimizationMode>() == OptimizationMode.DEBUG
|
||||
) // KT-65963
|
||||
val module = TestModule.Exclusive("moduleName", emptySet(), emptySet(), emptySet())
|
||||
val kexe = buildDir.resolve("kexe.kexe").also { it.delete() }
|
||||
val compilation = ExecutableCompilation(
|
||||
settings = testRunSettings,
|
||||
freeCompilerArgs = TestCompilerArgs.EMPTY,
|
||||
sourceModules = listOf(module),
|
||||
extras = TestCase.NoTestRunnerExtras("main"),
|
||||
dependencies = emptyList(),
|
||||
expectedArtifact = TestCompilationArtifact.Executable(kexe),
|
||||
tryPassSystemCacheDirectory = true
|
||||
)
|
||||
runProcess(konanc.absolutePath, source.absolutePath, *compilation.getCompilerArgs()) {
|
||||
timeout = Duration.parse("5m")
|
||||
}
|
||||
val runResult: RunProcessResult = with(testRunSettings) {
|
||||
executor.runProcess(kexe.absolutePath) {
|
||||
timeout = Duration.parse("1m")
|
||||
}
|
||||
}
|
||||
assertEquals("Hello, world!", runResult.stdout)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDriverVersion() {
|
||||
Assumptions.assumeFalse(HostManager.hostIsMingw &&
|
||||
testRunSettings.get<CacheMode>() == CacheMode.WithoutCache &&
|
||||
testRunSettings.get<OptimizationMode>() == OptimizationMode.DEBUG
|
||||
) // KT-65963
|
||||
// No need to test with different GC schedulers
|
||||
Assumptions.assumeFalse(testRunSettings.get<GCScheduler>() == GCScheduler.AGGRESSIVE)
|
||||
|
||||
val module = TestModule.Exclusive("moduleName", emptySet(), emptySet(), emptySet())
|
||||
val kexe = buildDir.resolve("kexe.kexe").also { it.delete() }
|
||||
val compilation = ExecutableCompilation(
|
||||
settings = testRunSettings,
|
||||
freeCompilerArgs = TestCompilerArgs(listOf("-version")),
|
||||
sourceModules = listOf(module),
|
||||
extras = TestCase.NoTestRunnerExtras("main"),
|
||||
dependencies = emptyList(),
|
||||
expectedArtifact = TestCompilationArtifact.Executable(kexe),
|
||||
tryPassSystemCacheDirectory = true
|
||||
)
|
||||
runProcess(konanc.absolutePath, source.absolutePath, *compilation.getCompilerArgs()) {
|
||||
timeout = Duration.parse("5m")
|
||||
}
|
||||
assertFalse(kexe.exists())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testOverrideKonanProperties() {
|
||||
Assumptions.assumeFalse(HostManager.hostIsMingw &&
|
||||
testRunSettings.get<CacheMode>() == CacheMode.WithoutCache &&
|
||||
testRunSettings.get<OptimizationMode>() == OptimizationMode.DEBUG
|
||||
) // KT-65963
|
||||
// No need to test with different GC schedulers
|
||||
Assumptions.assumeFalse(testRunSettings.get<GCScheduler>() == GCScheduler.AGGRESSIVE)
|
||||
|
||||
val module = TestModule.Exclusive("moduleName", emptySet(), emptySet(), emptySet())
|
||||
val kexe = buildDir.resolve("kexe.kexe").also { it.delete() }
|
||||
val compilation = ExecutableCompilation(
|
||||
settings = testRunSettings,
|
||||
freeCompilerArgs = TestCompilerArgs(
|
||||
listOf(
|
||||
"-opt",
|
||||
"-Xverbose-phases=MandatoryBitcodeLLVMPostprocessingPhase",
|
||||
if (HostManager.hostIsMingw)
|
||||
"-Xoverride-konan-properties=\"llvmInlineThreshold=76\""
|
||||
else "-Xoverride-konan-properties=llvmInlineThreshold=76"
|
||||
)),
|
||||
sourceModules = listOf(module),
|
||||
extras = TestCase.NoTestRunnerExtras("main"),
|
||||
dependencies = emptyList(),
|
||||
expectedArtifact = TestCompilationArtifact.Executable(kexe),
|
||||
tryPassSystemCacheDirectory = true
|
||||
)
|
||||
val compilationResult = runProcess(konanc.absolutePath, source.absolutePath, *compilation.getCompilerArgs()) {
|
||||
timeout = Duration.parse("5m")
|
||||
}
|
||||
val expected = "inline_threshold: 76"
|
||||
assertTrue(
|
||||
compilationResult.stdout.contains(expected),
|
||||
"Compiler's stdout must contain string: $expected\n" +
|
||||
"STDOUT:\n${compilationResult.stdout}\nSTDERR:${compilationResult.stderr}"
|
||||
)
|
||||
testRunSettings.executor.runProcess(kexe.absolutePath)
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -16,7 +16,7 @@ import kotlin.test.fail
|
||||
|
||||
@ExtendWith(NativeSimpleTestSupport::class)
|
||||
abstract class AbstractNativeSimpleTest {
|
||||
internal lateinit var testRunSettings: SimpleTestRunSettings
|
||||
lateinit var testRunSettings: SimpleTestRunSettings
|
||||
internal lateinit var testRunProvider: SimpleTestRunProvider
|
||||
|
||||
fun muteForK2(isK2: Boolean, test: () -> Unit) {
|
||||
|
||||
+1
-1
@@ -103,7 +103,7 @@ internal class ExecutableBuilder(
|
||||
}
|
||||
|
||||
internal val AbstractNativeSimpleTest.buildDir: File get() = testRunSettings.get<Binaries>().testBinariesDir
|
||||
internal val AbstractNativeSimpleTest.targets: KotlinNativeTargets get() = testRunSettings.get()
|
||||
val AbstractNativeSimpleTest.targets: KotlinNativeTargets get() = testRunSettings.get()
|
||||
|
||||
internal fun TestCompilationArtifact.KLIB.asLibraryDependency() =
|
||||
ExistingDependency(this, TestCompilationDependencyType.Library)
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ import kotlin.time.DurationUnit
|
||||
*
|
||||
* Handles all the necessary formatting right inside of [computeText]. Caches the resulting text to avoid re-computation.
|
||||
*/
|
||||
internal abstract class LoggedData {
|
||||
abstract class LoggedData {
|
||||
private val text: String by lazy { computeText() }
|
||||
protected abstract fun computeText(): String
|
||||
final override fun toString() = text
|
||||
|
||||
+2
-2
@@ -8,7 +8,7 @@ package org.jetbrains.kotlin.konan.test.blackbox.support
|
||||
/**
|
||||
* Represents a package name.
|
||||
*/
|
||||
internal class PackageName private constructor(private val fqn: String, val segments: List<String>): Comparable<PackageName> {
|
||||
class PackageName private constructor(private val fqn: String, val segments: List<String>): Comparable<PackageName> {
|
||||
constructor(segments: List<String>) : this(segments.joinToString("."), segments)
|
||||
constructor(fqn: String) : this(fqn, if (fqn.isNotEmpty()) fqn.split('.') else emptyList())
|
||||
|
||||
@@ -33,7 +33,7 @@ internal class PackageName private constructor(private val fqn: String, val segm
|
||||
* [packagePartClassName] - package-part class name (if there is any)
|
||||
* [functionName] - name of test function
|
||||
*/
|
||||
internal class TestName: Comparable<TestName> {
|
||||
class TestName: Comparable<TestName> {
|
||||
private val fqn: String
|
||||
|
||||
val packageName: PackageName
|
||||
|
||||
+5
-5
@@ -20,7 +20,7 @@ import java.io.File
|
||||
/**
|
||||
* Represents a single file that will be supplied to the compiler.
|
||||
*/
|
||||
internal class TestFile<M : TestModule> private constructor(
|
||||
class TestFile<M : TestModule> private constructor(
|
||||
val location: File,
|
||||
val module: M,
|
||||
private var state: State
|
||||
@@ -79,7 +79,7 @@ internal class TestFile<M : TestModule> private constructor(
|
||||
* [TestModule.Shared] represents a "shared" module, i.e. the auxiliary module that can be used in multiple [TestCase]s.
|
||||
* Such module is compiled to KLIB
|
||||
*/
|
||||
internal sealed class TestModule {
|
||||
sealed class TestModule {
|
||||
abstract val name: String
|
||||
abstract val files: Set<TestFile<*>>
|
||||
|
||||
@@ -157,7 +157,7 @@ internal sealed class TestModule {
|
||||
*
|
||||
* [testCaseGroupId] - a unique ID of [TestCaseGroup] this [TestCase] belongs to.
|
||||
*/
|
||||
internal interface TestCaseId {
|
||||
interface TestCaseId {
|
||||
val testCaseGroupId: TestCaseGroupId
|
||||
|
||||
data class TestDataFile(val file: File) : TestCaseId {
|
||||
@@ -181,7 +181,7 @@ internal interface TestCaseId {
|
||||
* [nominalPackageName] - the unique package name that was computed for this [TestCase] based on [id].
|
||||
* Note: It depends on the concrete [TestKind] whether the package name will be enforced for the [TestFile]s or not.
|
||||
*/
|
||||
internal class TestCase(
|
||||
class TestCase(
|
||||
val id: TestCaseId,
|
||||
val kind: TestKind,
|
||||
val modules: Set<TestModule.Exclusive>,
|
||||
@@ -281,7 +281,7 @@ internal class TestCase(
|
||||
/**
|
||||
* A unique identified of [TestCaseGroup].
|
||||
*/
|
||||
internal interface TestCaseGroupId {
|
||||
interface TestCaseGroupId {
|
||||
data class TestDataDir(val dir: File) : TestCaseGroupId
|
||||
data class Named(val uniqueName: String) : TestCaseGroupId
|
||||
}
|
||||
|
||||
+5
-5
@@ -201,7 +201,7 @@ internal object TestDirectives : SimpleDirectivesContainer() {
|
||||
}
|
||||
|
||||
// mimics class `JVMAssertionsMode`
|
||||
internal enum class AssertionsMode(val description: String) {
|
||||
enum class AssertionsMode(val description: String) {
|
||||
ALWAYS_ENABLE("always-enable"),
|
||||
ALWAYS_DISABLE("always-disable"),
|
||||
JVM("jvm"),
|
||||
@@ -214,20 +214,20 @@ internal enum class AssertionsMode(val description: String) {
|
||||
}
|
||||
}
|
||||
|
||||
internal enum class TestKind {
|
||||
enum class TestKind {
|
||||
REGULAR,
|
||||
STANDALONE,
|
||||
STANDALONE_NO_TR,
|
||||
STANDALONE_LLDB;
|
||||
}
|
||||
|
||||
internal enum class TestRunnerType {
|
||||
enum class TestRunnerType {
|
||||
DEFAULT,
|
||||
WORKER,
|
||||
NO_EXIT
|
||||
}
|
||||
|
||||
internal enum class MutedOption {
|
||||
enum class MutedOption {
|
||||
DEFAULT,
|
||||
K1,
|
||||
K2
|
||||
@@ -241,7 +241,7 @@ internal class TestCInteropArgs(cinteropArgs: List<String>) : TestCompilerArgs(e
|
||||
constructor(vararg cinteropArgs: String) : this(cinteropArgs.asList())
|
||||
}
|
||||
|
||||
internal open class TestCompilerArgs(
|
||||
open class TestCompilerArgs(
|
||||
val compilerArgs: List<String>,
|
||||
val cinteropArgs: List<String> = emptyList(),
|
||||
val assertionsMode: AssertionsMode = AssertionsMode.DEFAULT,
|
||||
|
||||
+5
-5
@@ -33,11 +33,11 @@ private fun AssertionsMode.assertionsEnabledWith(optimizationMode: OptimizationM
|
||||
else -> optimizationMode != OptimizationMode.OPT
|
||||
}
|
||||
|
||||
internal abstract class TestCompilation<A : TestCompilationArtifact> {
|
||||
abstract class TestCompilation<A : TestCompilationArtifact> {
|
||||
abstract val result: TestCompilationResult<out A>
|
||||
}
|
||||
|
||||
internal abstract class BasicCompilation<A : TestCompilationArtifact>(
|
||||
abstract class BasicCompilation<A : TestCompilationArtifact>(
|
||||
protected val targets: KotlinNativeTargets,
|
||||
protected val home: KotlinNativeHome,
|
||||
private val classLoader: KotlinNativeClassLoader,
|
||||
@@ -184,7 +184,7 @@ internal abstract class BasicCompilation<A : TestCompilationArtifact>(
|
||||
}
|
||||
}
|
||||
|
||||
internal abstract class SourceBasedCompilation<A : TestCompilationArtifact>(
|
||||
abstract class SourceBasedCompilation<A : TestCompilationArtifact>(
|
||||
targets: KotlinNativeTargets,
|
||||
home: KotlinNativeHome,
|
||||
classLoader: KotlinNativeClassLoader,
|
||||
@@ -491,7 +491,7 @@ internal class SwiftCompilation<T: TestCompilationArtifact>(
|
||||
}
|
||||
}
|
||||
|
||||
internal class ExecutableCompilation(
|
||||
class ExecutableCompilation(
|
||||
settings: Settings,
|
||||
freeCompilerArgs: TestCompilerArgs,
|
||||
sourceModules: Collection<TestModule>,
|
||||
@@ -664,7 +664,7 @@ internal class StaticCacheCompilation(
|
||||
}
|
||||
}
|
||||
|
||||
internal class CategorizedDependencies(uncategorizedDependencies: Iterable<TestCompilationDependency<*>>) {
|
||||
class CategorizedDependencies(uncategorizedDependencies: Iterable<TestCompilationDependency<*>>) {
|
||||
val failures: Set<TestCompilationResult.Failure> by lazy {
|
||||
uncategorizedDependencies.flatMapToSet { dependency ->
|
||||
when (val result = (dependency as? TestCompilation<*>)?.result) {
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ package org.jetbrains.kotlin.konan.test.blackbox.support.compilation
|
||||
|
||||
import java.io.File
|
||||
|
||||
internal sealed interface TestCompilationArtifact {
|
||||
sealed interface TestCompilationArtifact {
|
||||
val logFile: File
|
||||
|
||||
data class KLIB(val klibFile: File) : TestCompilationArtifact {
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ import org.jetbrains.kotlin.konan.test.blackbox.support.compilation.TestCompilat
|
||||
* [IncludedLibrary] - similarly but included modules (-Xinclude).
|
||||
* Note: there cannot be DependsOnLibrary type, since `dependsOn` dependency works only within a KLIB, not between KLIBs.
|
||||
*/
|
||||
internal sealed class TestCompilationDependencyType<A : TestCompilationArtifact>(private val artifactClass: Class<A>) {
|
||||
sealed class TestCompilationDependencyType<A : TestCompilationArtifact>(private val artifactClass: Class<A>) {
|
||||
object Library : TestCompilationDependencyType<KLIB>(KLIB::class.java)
|
||||
object FriendLibrary : TestCompilationDependencyType<KLIB>(KLIB::class.java)
|
||||
object IncludedLibrary : TestCompilationDependencyType<KLIB>(KLIB::class.java)
|
||||
@@ -26,7 +26,7 @@ internal sealed class TestCompilationDependencyType<A : TestCompilationArtifact>
|
||||
object LibraryStaticCache : TestCompilationDependencyType<KLIBStaticCache>(KLIBStaticCache::class.java)
|
||||
}
|
||||
|
||||
internal sealed interface TestCompilationDependency<A : TestCompilationArtifact> {
|
||||
sealed interface TestCompilationDependency<A : TestCompilationArtifact> {
|
||||
val artifact: A
|
||||
val type: TestCompilationDependencyType<A>
|
||||
}
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ class CompilationToolException(val reason: String) : Exception() {
|
||||
override fun toString() = "CompilationToolException: $reason"
|
||||
}
|
||||
|
||||
internal sealed interface TestCompilationResult<A : TestCompilationArtifact> {
|
||||
sealed interface TestCompilationResult<A : TestCompilationArtifact> {
|
||||
sealed interface ImmediateResult<A : TestCompilationArtifact> : TestCompilationResult<A> {
|
||||
val loggedData: LoggedData
|
||||
}
|
||||
|
||||
+2
-2
@@ -8,7 +8,7 @@ package org.jetbrains.kotlin.konan.test.blackbox.support.runner
|
||||
import org.jetbrains.kotlin.konan.test.blackbox.support.util.TestOutputFilter
|
||||
import kotlin.time.Duration
|
||||
|
||||
internal data class RunResult(
|
||||
data class RunResult(
|
||||
val testExecutable: TestExecutable, // KT-62157: TODO extract out of RunResult and pass Pair(TestExecutable, RunResult)
|
||||
val exitCode: Int?,
|
||||
val timeout: Duration,
|
||||
@@ -22,4 +22,4 @@ internal data class RunResult(
|
||||
}
|
||||
}
|
||||
|
||||
internal class ProcessOutput(val stdOut: TestOutputFilter.FilteredOutput, val stdErr: String)
|
||||
class ProcessOutput(val stdOut: TestOutputFilter.FilteredOutput, val stdErr: String)
|
||||
|
||||
+3
-3
@@ -16,7 +16,7 @@ import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
|
||||
internal class TestExecutable(
|
||||
class TestExecutable(
|
||||
val executable: Executable,
|
||||
val loggedCompilationToolCall: LoggedData.CompilerCall,
|
||||
val testNames: Collection<TestName>
|
||||
@@ -50,7 +50,7 @@ internal class TestExecutable(
|
||||
}
|
||||
}
|
||||
|
||||
internal data class TestRun(
|
||||
data class TestRun(
|
||||
val displayName: String,
|
||||
val executable: TestExecutable,
|
||||
val runParameters: List<TestRunParameter>,
|
||||
@@ -59,7 +59,7 @@ internal data class TestRun(
|
||||
val expectedFailure: Boolean,
|
||||
)
|
||||
|
||||
internal sealed interface TestRunParameter {
|
||||
sealed interface TestRunParameter {
|
||||
fun applyTo(programArgs: MutableList<String>)
|
||||
|
||||
sealed class WithFilter : TestRunParameter {
|
||||
|
||||
+2
-2
@@ -28,7 +28,7 @@ import org.junit.jupiter.api.Assumptions
|
||||
import java.io.File
|
||||
import kotlin.time.Duration
|
||||
|
||||
internal sealed interface TestRunCheck {
|
||||
sealed interface TestRunCheck {
|
||||
|
||||
fun apply(testRun: TestRun, runResult: RunResult): Result
|
||||
|
||||
@@ -280,7 +280,7 @@ internal sealed interface TestRunCheck {
|
||||
}
|
||||
}
|
||||
|
||||
internal data class TestRunChecks(
|
||||
data class TestRunChecks(
|
||||
val executionTimeoutCheck: ExecutionTimeout,
|
||||
val testFiltering: TestFiltering,
|
||||
private val exitCodeCheck: ExitCode?,
|
||||
|
||||
+4
-4
@@ -13,7 +13,7 @@ import org.jetbrains.kotlin.test.services.JUnit5Assertions.assertTrue
|
||||
import org.jetbrains.kotlin.test.services.JUnit5Assertions.fail
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
internal abstract class Settings(private val parent: Settings?, settings: Iterable<Any>) {
|
||||
abstract class Settings(private val parent: Settings?, settings: Iterable<Any>) {
|
||||
private val map: Map<KClass<*>, Any> = buildMap {
|
||||
settings.forEach {
|
||||
val settingClass: KClass<*>
|
||||
@@ -48,7 +48,7 @@ internal abstract class Settings(private val parent: Settings?, settings: Iterab
|
||||
* | [TestClassSettings] | [TestProcessSettings] | The single top-level (enclosing) test class |
|
||||
* | [TestRunSettings] | [TestClassSettings] | The single test run of a test function |
|
||||
*/
|
||||
internal class TestProcessSettings(vararg settings: Any) : Settings(parent = null, settings.asIterable())
|
||||
class TestProcessSettings(vararg settings: Any) : Settings(parent = null, settings.asIterable())
|
||||
internal class TestClassSettings(parent: TestProcessSettings, settings: Iterable<Any>) : Settings(parent, settings)
|
||||
internal class TestRunSettings(parent: TestClassSettings, settings: Iterable<Any>) : Settings(parent, settings)
|
||||
|
||||
@@ -61,8 +61,8 @@ internal class TestRunSettings(parent: TestClassSettings, settings: Iterable<Any
|
||||
* | [SimpleTestClassSettings] | [TestProcessSettings] | The single top-level (enclosing) test class |
|
||||
* | [SimpleTestRunSettings] | [SimpleTestClassSettings] | The single test run of a test function |
|
||||
*/
|
||||
internal class SimpleTestClassSettings(parent: TestProcessSettings, settings: Iterable<Any>) : Settings(parent, settings)
|
||||
internal class SimpleTestRunSettings(parent: SimpleTestClassSettings, settings: Iterable<Any>) : Settings(parent, settings)
|
||||
class SimpleTestClassSettings(parent: TestProcessSettings, settings: Iterable<Any>) : Settings(parent, settings)
|
||||
class SimpleTestRunSettings(parent: SimpleTestClassSettings, settings: Iterable<Any>) : Settings(parent, settings)
|
||||
|
||||
internal val Settings.configurables: Configurables
|
||||
get() {
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
private val executorCache: ConcurrentHashMap<KonanTarget, Executor> = ConcurrentHashMap()
|
||||
|
||||
internal val Settings.executor: Executor
|
||||
val Settings.executor: Executor
|
||||
get() = with(get<KotlinNativeTargets>()) {
|
||||
executorCache.computeIfAbsent(testTarget) {
|
||||
val configurables = configurables
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ internal class GeneratedSources(val testSourcesDir: File, val sharedSourcesDir:
|
||||
* [sharedBinariesDir] - The directory with compiled shared modules (klibs).
|
||||
* [givenBinariesDir] - The directory with the given (external) modules (klibs).
|
||||
*/
|
||||
internal class Binaries(val testBinariesDir: File, lazySharedBinariesDir: () -> File, lazyGivenBinariesDir: () -> File) {
|
||||
class Binaries(val testBinariesDir: File, lazySharedBinariesDir: () -> File, lazyGivenBinariesDir: () -> File) {
|
||||
val sharedBinariesDir: File by lazy { lazySharedBinariesDir() }
|
||||
val givenBinariesDir: File by lazy { lazyGivenBinariesDir() }
|
||||
}
|
||||
|
||||
+13
-13
@@ -25,14 +25,14 @@ import kotlin.time.Duration.Companion.seconds
|
||||
/**
|
||||
* The tested and the host Kotlin/Native targets.
|
||||
*/
|
||||
internal class KotlinNativeTargets(val testTarget: KonanTarget, val hostTarget: KonanTarget) {
|
||||
class KotlinNativeTargets(val testTarget: KonanTarget, val hostTarget: KonanTarget) {
|
||||
fun areDifferentTargets() = testTarget != hostTarget
|
||||
}
|
||||
|
||||
/**
|
||||
* The Kotlin/Native home.
|
||||
*/
|
||||
internal class KotlinNativeHome(val dir: File) {
|
||||
class KotlinNativeHome(val dir: File) {
|
||||
val librariesDir: File = dir.resolve("klib")
|
||||
val stdlibFile: File = librariesDir.resolve("common/stdlib")
|
||||
val properties: Properties by lazy {
|
||||
@@ -56,7 +56,7 @@ internal class LLDB(nativeHome: KotlinNativeHome) {
|
||||
/**
|
||||
* Lazy-initialized class loader with the Kotlin/Native embedded compiler.
|
||||
*/
|
||||
internal class KotlinNativeClassLoader(private val lazyClassLoader: Lazy<ClassLoader>) {
|
||||
class KotlinNativeClassLoader(private val lazyClassLoader: Lazy<ClassLoader>) {
|
||||
val classLoader: ClassLoader get() = lazyClassLoader.value
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ internal enum class TestMode(private val description: String) {
|
||||
* Kotlin compiler plugins to be used together with the the Kotlin/Native compiler.
|
||||
*/
|
||||
@JvmInline
|
||||
internal value class CompilerPlugins(val compilerPluginJars: Set<File>) {
|
||||
value class CompilerPlugins(val compilerPluginJars: Set<File>) {
|
||||
init {
|
||||
val invalidJars = compilerPluginJars.filterNot { it.isDirectory || (it.isFile && it.extension == "jar") }
|
||||
assertTrue(invalidJars.isEmpty()) {
|
||||
@@ -122,7 +122,7 @@ internal value class SharedExecutionTestRunner(val value: Boolean)
|
||||
/**
|
||||
* Optimization mode to be applied.
|
||||
*/
|
||||
internal enum class OptimizationMode(private val description: String, val compilerFlag: String?) {
|
||||
enum class OptimizationMode(private val description: String, val compilerFlag: String?) {
|
||||
DEBUG("Build with debug information", "-g"),
|
||||
OPT("Build with optimizations applied", "-opt"),
|
||||
NO("Don't use any specific optimizations", null);
|
||||
@@ -133,7 +133,7 @@ internal enum class OptimizationMode(private val description: String, val compil
|
||||
/**
|
||||
* Thread state checked. Can be applied only with [OptimizationMode.DEBUG], [CacheMode.WithoutCache].
|
||||
*/
|
||||
internal enum class ThreadStateChecker(val compilerFlag: String?) {
|
||||
enum class ThreadStateChecker(val compilerFlag: String?) {
|
||||
DISABLED(null),
|
||||
ENABLED("-Xbinary=checkStateAtExternalCalls=true");
|
||||
|
||||
@@ -143,7 +143,7 @@ internal enum class ThreadStateChecker(val compilerFlag: String?) {
|
||||
/**
|
||||
* Type of sanitizer. Can be applied only with [CacheMode.WithoutCache]
|
||||
*/
|
||||
internal enum class Sanitizer(val compilerFlag: String?) {
|
||||
enum class Sanitizer(val compilerFlag: String?) {
|
||||
NONE(null),
|
||||
THREAD("-Xbinary=sanitizer=thread");
|
||||
|
||||
@@ -153,7 +153,7 @@ internal enum class Sanitizer(val compilerFlag: String?) {
|
||||
/**
|
||||
* Garbage collector type.
|
||||
*/
|
||||
internal enum class GCType(val compilerFlag: String?) {
|
||||
enum class GCType(val compilerFlag: String?) {
|
||||
UNSPECIFIED(null),
|
||||
NOOP("-Xbinary=gc=noop"),
|
||||
STWMS("-Xbinary=gc=stwms"),
|
||||
@@ -166,7 +166,7 @@ internal enum class GCType(val compilerFlag: String?) {
|
||||
override fun toString() = compilerFlag?.let { "($it)" }.orEmpty()
|
||||
}
|
||||
|
||||
internal enum class GCScheduler(val compilerFlag: String?) {
|
||||
enum class GCScheduler(val compilerFlag: String?) {
|
||||
UNSPECIFIED(null),
|
||||
MANUAL("-Xbinary=gcSchedulerType=manual"),
|
||||
ADAPTIVE("-Xbinary=gcSchedulerType=adaptive"),
|
||||
@@ -180,7 +180,7 @@ internal enum class GCScheduler(val compilerFlag: String?) {
|
||||
override fun toString() = compilerFlag?.let { "($it)" }.orEmpty()
|
||||
}
|
||||
|
||||
internal enum class Allocator(val compilerFlag: String?) {
|
||||
enum class Allocator(val compilerFlag: String?) {
|
||||
UNSPECIFIED(null),
|
||||
STD("-Xallocator=std"),
|
||||
MIMALLOC("-Xallocator=mimalloc"),
|
||||
@@ -206,7 +206,7 @@ internal class Timeouts(val executionTimeout: Duration) {
|
||||
/**
|
||||
* Used cache mode.
|
||||
*/
|
||||
internal sealed class CacheMode {
|
||||
sealed class CacheMode {
|
||||
abstract val staticCacheForDistributionLibrariesRootDir: File?
|
||||
abstract val useStaticCacheForUserLibraries: Boolean
|
||||
abstract val makePerFileCaches: Boolean
|
||||
@@ -283,7 +283,7 @@ internal sealed class CacheMode {
|
||||
}
|
||||
}
|
||||
|
||||
internal enum class PipelineType(val mutedOption: MutedOption, val compilerFlags: List<String>) {
|
||||
enum class PipelineType(val mutedOption: MutedOption, val compilerFlags: List<String>) {
|
||||
DEFAULT(
|
||||
MutedOption.DEFAULT,
|
||||
emptyList()
|
||||
@@ -300,7 +300,7 @@ internal enum class PipelineType(val mutedOption: MutedOption, val compilerFlags
|
||||
override fun toString() = if (compilerFlags.isEmpty()) "" else compilerFlags.joinToString(prefix = "(", postfix = ")", separator = " ")
|
||||
}
|
||||
|
||||
internal enum class CompilerOutputInterceptor {
|
||||
enum class CompilerOutputInterceptor {
|
||||
DEFAULT,
|
||||
NONE
|
||||
}
|
||||
|
||||
+4
-4
@@ -5,7 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.konan.test.blackbox.support.util
|
||||
|
||||
internal class ArgsBuilder {
|
||||
class ArgsBuilder {
|
||||
private val args = mutableListOf<String>()
|
||||
|
||||
fun add(vararg args: String) {
|
||||
@@ -16,15 +16,15 @@ internal class ArgsBuilder {
|
||||
this.args += args
|
||||
}
|
||||
|
||||
inline fun <T> add(rawArgs: Iterable<T>, transform: (T) -> String) {
|
||||
fun <T> add(rawArgs: Iterable<T>, transform: (T) -> String) {
|
||||
rawArgs.mapTo(args) { transform(it) }
|
||||
}
|
||||
|
||||
inline fun <T> addFlattened(rawArgs: Iterable<T>, transform: (T) -> Iterable<String>) {
|
||||
fun <T> addFlattened(rawArgs: Iterable<T>, transform: (T) -> Iterable<String>) {
|
||||
rawArgs.flatMapTo(args) { transform(it) }
|
||||
}
|
||||
|
||||
inline fun <T, R> addFlattenedTwice(rawArgs: Iterable<T>, transform1: (T) -> Iterable<R>, transform2: (R) -> String) {
|
||||
fun <T, R> addFlattenedTwice(rawArgs: Iterable<T>, transform1: (T) -> Iterable<R>, transform2: (R) -> String) {
|
||||
rawArgs.forEach { add(transform1(it), transform2) }
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ import java.util.*
|
||||
internal fun <T> Collection<T>.toIdentitySet(): Set<T> =
|
||||
Collections.newSetFromMap(IdentityHashMap<T, Boolean>()).apply { addAll(this@toIdentitySet) }
|
||||
|
||||
internal class FailOnDuplicatesSet<E : Any> : Set<E> {
|
||||
class FailOnDuplicatesSet<E : Any> : Set<E> {
|
||||
private val uniqueElements: MutableSet<E> = hashSetOf()
|
||||
|
||||
operator fun plusAssign(element: E) {
|
||||
|
||||
+2
-2
@@ -11,7 +11,7 @@ import org.jetbrains.kotlin.test.services.JUnit5Assertions.assertTrue
|
||||
import java.text.ParseException
|
||||
import org.jetbrains.kotlin.konan.test.blackbox.support.util.TCTestReportParseState as State
|
||||
|
||||
internal class TestReport(
|
||||
class TestReport(
|
||||
val passedTests: Collection<TestName>,
|
||||
val failedTests: Collection<TestName>,
|
||||
val ignoredTests: Collection<TestName>
|
||||
@@ -26,7 +26,7 @@ internal class TestReport(
|
||||
""".trimIndent()
|
||||
}
|
||||
|
||||
internal interface TestOutputFilter {
|
||||
interface TestOutputFilter {
|
||||
fun filter(testOutput: String): FilteredOutput
|
||||
|
||||
data class FilteredOutput(val filteredOutput: String, val testReport: TestReport?)
|
||||
|
||||
Reference in New Issue
Block a user