[K/N][tests] Migrate first platform-dependent test to new testing infra
^KT-61259
This commit is contained in:
committed by
Vladimir Sukharev
parent
4786c945d9
commit
b7fbfb2fde
@@ -228,40 +228,6 @@ Task standaloneTest(String name, Closure configureClosure) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a task for a linking test. Configures runner and adds library and test build tasks.
|
||||
*/
|
||||
Task linkTest(String name, Closure<KonanLinkTest> configureClosure) {
|
||||
return KotlinNativeTestKt.createTest(project, name, KonanLinkTest) { task ->
|
||||
task.configure(configureClosure)
|
||||
if (task.enabled) {
|
||||
konanArtifacts {
|
||||
def lib = "lib$name"
|
||||
def targetName = target.name
|
||||
// build a library from KonanLinkTest::lib property
|
||||
library(lib, targets: [targetName]) {
|
||||
srcFiles task.lib
|
||||
baseDir "$testOutputLocal/$name"
|
||||
extraOpts task.flags
|
||||
extraOpts project.globalTestArgs.findAll { !it.contains("-Xpartial-linkage") }
|
||||
}
|
||||
UtilsKt.dependsOnKonanBuildingTask(task, lib, target)
|
||||
|
||||
// Build an executable with library
|
||||
program(name, targets: [targetName]) {
|
||||
libraries {
|
||||
klibFile file("$testOutputLocal/$name/$targetName/${lib}.klib")
|
||||
}
|
||||
baseDir "$testOutputLocal/$name"
|
||||
srcFiles task.getSources()
|
||||
extraOpts task.flags
|
||||
extraOpts project.globalTestArgs
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a task for a dynamic test. Configures runner and adds library and test build tasks.
|
||||
*/
|
||||
@@ -575,13 +541,6 @@ standaloneTest("link_default_libs") {
|
||||
UtilsKt.dependsOnPlatformLibs(it)
|
||||
}
|
||||
|
||||
linkTest("no_purge_for_dependencies") {
|
||||
useGoldenData = true
|
||||
source = "link/purge1/prog.kt"
|
||||
lib = "link/purge1/lib.kt"
|
||||
UtilsKt.dependsOnPlatformLibs(it)
|
||||
}
|
||||
|
||||
standaloneTest("check_stacktrace_format_coresymbolication") {
|
||||
disabled = !PlatformInfo.supportsCoreSymbolication(project) || project.globalTestArgs.contains('-opt')
|
||||
flags = ['-g', '-Xbinary=sourceInfoType=coresymbolication']
|
||||
@@ -1333,7 +1292,7 @@ Task interopTestBase(String name, boolean multiFile, boolean interop2ForMainOnly
|
||||
def lib = "lib$name"
|
||||
def hasIntermediateLib = task.lib != null
|
||||
if (hasIntermediateLib) {
|
||||
// build a library from KonanLinkTest::lib property
|
||||
// build a library from KonanInteropTest::lib property
|
||||
library(lib, targets: [targetName]) {
|
||||
libraries {
|
||||
artifact interopLib
|
||||
@@ -2693,9 +2652,6 @@ task buildKonanTests { t ->
|
||||
.withType(KonanStandaloneTest.class)
|
||||
.each {
|
||||
// add library and source files
|
||||
if (it instanceof KonanLinkTest) {
|
||||
excludeList += it.lib
|
||||
}
|
||||
if (it.source != null) {
|
||||
excludeList += it.source
|
||||
}
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2023 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.
|
||||
*/
|
||||
@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||
|
||||
import kotlinx.cinterop.convert
|
||||
import platform.posix.*
|
||||
|
||||
fun foo() {
|
||||
println("linked library")
|
||||
val size: size_t = 17.convert<size_t>()
|
||||
val e = fabs(1.toDouble())
|
||||
println("and symbols from posix available: $size; $e")
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2023 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.
|
||||
*/
|
||||
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
foo()
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
linked library
|
||||
and symbols from posix available: 17; 1.0
|
||||
@@ -429,11 +429,6 @@ open class KonanInteropTest : KonanStandaloneTest() {
|
||||
var lib: String? = null
|
||||
}
|
||||
|
||||
open class KonanLinkTest : KonanStandaloneTest() {
|
||||
@Input
|
||||
lateinit var lib: String
|
||||
}
|
||||
|
||||
/**
|
||||
* Test task to check a library built by `-produce dynamic`.
|
||||
* C source code should contain `testlib` as a reference to a testing library.
|
||||
|
||||
@@ -86,11 +86,6 @@ fun Task.dependsOnPlatformLibs() {
|
||||
this.dependsOn(":kotlin-native:platformLibs:${project.testTarget.name}-$it")
|
||||
//this.dependsOn(":kotlin-native:platformLibs:${project.testTarget.name}-${it}Cache")
|
||||
}
|
||||
if (this is KonanLinkTest) {
|
||||
project.file(lib).dependencies().forEach {
|
||||
this.dependsOn(":kotlin-native:platformLibs:${project.testTarget.name}-$it")
|
||||
}
|
||||
}
|
||||
this.dependsOnDist()
|
||||
} ?: error("unsupported task : $this")
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
|
||||
@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||
|
||||
import kotlinx.cinterop.convert
|
||||
import platform.posix.*
|
||||
|
||||
fun foo(): String {
|
||||
val size: size_t = 17.convert<size_t>()
|
||||
val e = fabs(1.toDouble())
|
||||
return "$size; $e"
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: main.kt
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
assertEquals("17; 1.0", foo())
|
||||
return "OK"
|
||||
}
|
||||
+6
@@ -3221,6 +3221,12 @@ public class FirNativeCodegenLocalTestGenerated extends AbstractNativeCodegenBox
|
||||
runTest("native/native.tests/testData/codegen/link/link.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("noPurgeForDependencies.kt")
|
||||
public void testNoPurgeForDependencies() throws Exception {
|
||||
runTest("native/native.tests/testData/codegen/link/noPurgeForDependencies.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("omitUnused.kt")
|
||||
public void testOmitUnused() throws Exception {
|
||||
|
||||
+6
@@ -3147,6 +3147,12 @@ public class NativeCodegenLocalTestGenerated extends AbstractNativeCodegenBoxTes
|
||||
runTest("native/native.tests/testData/codegen/link/link.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("noPurgeForDependencies.kt")
|
||||
public void testNoPurgeForDependencies() throws Exception {
|
||||
runTest("native/native.tests/testData/codegen/link/noPurgeForDependencies.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("omitUnused.kt")
|
||||
public void testOmitUnused() throws Exception {
|
||||
|
||||
+2
@@ -303,6 +303,7 @@ private class ExtTestDataFile(
|
||||
|| importedFqName.startsWith(KOTLINX_PACKAGE_NAME)
|
||||
|| importedFqName.startsWith(HELPERS_PACKAGE_NAME)
|
||||
|| importedFqName.startsWith(CNAMES_PACKAGE_NAME)
|
||||
|| importedFqName.startsWith(PLATFORM_PACKAGE_NAME)
|
||||
) {
|
||||
return
|
||||
}
|
||||
@@ -596,6 +597,7 @@ private class ExtTestDataFile(
|
||||
private val HELPERS_PACKAGE_NAME = Name.identifier("helpers")
|
||||
private val KOTLINX_PACKAGE_NAME = Name.identifier("kotlinx")
|
||||
private val CNAMES_PACKAGE_NAME = Name.identifier("cnames")
|
||||
private val PLATFORM_PACKAGE_NAME = Name.identifier("platform")
|
||||
|
||||
private val MANDATORY_SOURCE_TRANSFORMERS: ExternalSourceTransformers = listOf(DiagnosticsRemovingSourceTransformer)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user