[Native][tests] Port KT-36639 test case to the new infra

This commit is contained in:
Sergey Bogolepov
2023-12-05 14:00:13 +02:00
committed by Space Team
parent 1c24f994db
commit c165171471
9 changed files with 171 additions and 12 deletions
@@ -18,6 +18,7 @@ import org.jetbrains.kotlin.konan.test.blackbox.support.compilation.TestCompilat
import org.jetbrains.kotlin.konan.test.blackbox.support.compilation.TestCompilationFactory
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.konan.test.blackbox.support.runner.TestRunCheck
import org.jetbrains.kotlin.konan.test.blackbox.support.runner.TestRunChecks
import org.jetbrains.kotlin.konan.test.blackbox.support.settings.Timeouts
import org.jetbrains.kotlin.konan.test.blackbox.support.settings.configurables
@@ -51,7 +52,11 @@ abstract class AbstractNativeCExportTest(
.filter { it.endsWith(".c") }
.map { testPathFull.resolve(it) }
val testCase = generateCExportTestCase(testPathFull, ktSources)
val goldenData = testPathFull.list()!!
.singleOrNull { it.endsWith(".out") }
?.let { testPathFull.resolve(it) }
val testCase = generateCExportTestCase(testPathFull, ktSources, goldenData = goldenData)
val binaryLibrary = testCompilationFactory.testCaseToBinaryLibrary(
testCase,
testRunSettings,
@@ -80,7 +85,7 @@ abstract class AbstractNativeCExportTest(
runExecutableAndVerify(testCase, testExecutable)
}
private fun generateCExportTestCase(testPathFull: File, sources: List<File>): TestCase {
private fun generateCExportTestCase(testPathFull: File, sources: List<File>, goldenData: File? = null): TestCase {
val moduleName: String = testPathFull.name
val module = TestModule.Exclusive(DEFAULT_MODULE_NAME, emptySet(), emptySet(), emptySet())
sources.forEach { module.files += TestFile.createCommitted(it, module) }
@@ -94,7 +99,7 @@ abstract class AbstractNativeCExportTest(
checks = TestRunChecks(
executionTimeoutCheck = TestRunCheck.ExecutionTimeout.ShouldNotExceed(testRunSettings.get<Timeouts>().executionTimeout),
exitCodeCheck = TestRunCheck.ExitCode.Expected(0),
outputDataFile = goldenData?.let { TestRunCheck.OutputDataFile(file = it) },
outputDataFile = goldenData?.let { TestRunCheck.OutputDataFile(it) },
outputMatcher = null,
fileCheckMatcher = null,
),