[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
@@ -0,0 +1,6 @@
CFoo1::extfoo
CFoo1::extfoo
CFoo2::extfoo
CFoo2::extfoo
Int::extfoo
Int::extfoo
+28
View File
@@ -0,0 +1,28 @@
#include "kt36639_api.h"
#define __ kt36639_symbols()->
#define T_(x) kt36639_kref_ ## x
int
main() {
T_(CFoo1) foo1 = __ kotlin.root.CFoo1.CFoo1();
T_(CFoo2) foo2 = __ kotlin.root.CFoo2.CFoo2();
T_(kotlin_Int) intV = __ createNullableInt(42);
T_(kotlin_Any) any;
T_(Foo) foo = { .pinned = foo1.pinned };
any.pinned = foo1.pinned;
__ kotlin.root.CFoo1.callMe(foo1, any);
__ kotlin.root.Foo.extfoo(foo, any);
any.pinned = foo2.pinned;
__ kotlin.root.CFoo1.callMe(foo1, any);
__ kotlin.root.Foo.extfoo(foo, any);
any.pinned = intV.pinned;
__ kotlin.root.CFoo1.callMe(foo1, any);
__ kotlin.root.Foo.extfoo(foo, any);
__ DisposeStablePointer(foo1.pinned);
__ DisposeStablePointer(foo2.pinned);
__ DisposeStablePointer(intV.pinned);
}
+21
View File
@@ -0,0 +1,21 @@
interface Foo {
fun Any.extfoo()
}
class CFoo1:Foo {
override fun Any.extfoo() {
when(this) {
is CFoo1 -> println("CFoo1::extfoo")
is CFoo2 -> println("CFoo2::extfoo")
is Int -> println("Int::extfoo")
}
}
fun callMe(arg: Any) = arg.extfoo()
}
class CFoo2:Foo {
override fun Any.extfoo() {
TODO("Not yet implemented")
}
}
@@ -0,0 +1,38 @@
/*
* 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.blackbox;
import com.intellij.testFramework.TestDataPath;
import org.jetbrains.kotlin.test.util.KtTestUtil;
import org.jetbrains.kotlin.test.TestMetadata;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import java.io.File;
import java.util.regex.Pattern;
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.GenerateNativeTestsKt}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("native/native.tests/testData/CExport")
@TestDataPath("$PROJECT_ROOT")
public class CExportTestDynamicGenerated extends AbstractNativeCExportDynamicTest {
@Test
public void testAllFilesPresentInCExport() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/CExport"), Pattern.compile("^([^_](.+))$"), null, false);
}
@Test
@TestMetadata("kt36639")
public void testKt36639() throws Exception {
runTest("native/native.tests/testData/CExport/kt36639/");
}
@Test
@TestMetadata("smoke0")
public void testSmoke0() throws Exception {
runTest("native/native.tests/testData/CExport/smoke0/");
}
}
@@ -0,0 +1,38 @@
/*
* 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.blackbox;
import com.intellij.testFramework.TestDataPath;
import org.jetbrains.kotlin.test.util.KtTestUtil;
import org.jetbrains.kotlin.test.TestMetadata;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import java.io.File;
import java.util.regex.Pattern;
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.GenerateNativeTestsKt}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("native/native.tests/testData/CExport")
@TestDataPath("$PROJECT_ROOT")
public class CExportTestStaticGenerated extends AbstractNativeCExportStaticTest {
@Test
public void testAllFilesPresentInCExport() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/CExport"), Pattern.compile("^([^_](.+))$"), null, false);
}
@Test
@TestMetadata("kt36639")
public void testKt36639() throws Exception {
runTest("native/native.tests/testData/CExport/kt36639/");
}
@Test
@TestMetadata("smoke0")
public void testSmoke0() throws Exception {
runTest("native/native.tests/testData/CExport/smoke0/");
}
}
@@ -0,0 +1,42 @@
/*
* 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.blackbox;
import com.intellij.testFramework.TestDataPath;
import org.jetbrains.kotlin.test.util.KtTestUtil;
import org.junit.jupiter.api.Tag;
import org.jetbrains.kotlin.konan.test.blackbox.support.group.FirPipeline;
import org.jetbrains.kotlin.test.TestMetadata;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import java.io.File;
import java.util.regex.Pattern;
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.GenerateNativeTestsKt}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("native/native.tests/testData/CExport")
@TestDataPath("$PROJECT_ROOT")
@Tag("frontend-fir")
@FirPipeline()
public class FirCExportTestDynamicGenerated extends AbstractNativeCExportDynamicTest {
@Test
public void testAllFilesPresentInCExport() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/CExport"), Pattern.compile("^([^_](.+))$"), null, false);
}
@Test
@TestMetadata("kt36639")
public void testKt36639() throws Exception {
runTest("native/native.tests/testData/CExport/kt36639/");
}
@Test
@TestMetadata("smoke0")
public void testSmoke0() throws Exception {
runTest("native/native.tests/testData/CExport/smoke0/");
}
}
@@ -0,0 +1,42 @@
/*
* 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.blackbox;
import com.intellij.testFramework.TestDataPath;
import org.jetbrains.kotlin.test.util.KtTestUtil;
import org.junit.jupiter.api.Tag;
import org.jetbrains.kotlin.konan.test.blackbox.support.group.FirPipeline;
import org.jetbrains.kotlin.test.TestMetadata;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import java.io.File;
import java.util.regex.Pattern;
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.GenerateNativeTestsKt}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("native/native.tests/testData/CExport")
@TestDataPath("$PROJECT_ROOT")
@Tag("frontend-fir")
@FirPipeline()
public class FirCExportTestStaticGenerated extends AbstractNativeCExportStaticTest {
@Test
public void testAllFilesPresentInCExport() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/CExport"), Pattern.compile("^([^_](.+))$"), null, false);
}
@Test
@TestMetadata("kt36639")
public void testKt36639() throws Exception {
runTest("native/native.tests/testData/CExport/kt36639/");
}
@Test
@TestMetadata("smoke0")
public void testSmoke0() throws Exception {
runTest("native/native.tests/testData/CExport/smoke0/");
}
}
@@ -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,
),