[K/N][tests] Migrate first platform-dependent test to new testing infra

^KT-61259
This commit is contained in:
Alexander Shabalin
2023-12-20 18:52:02 +01:00
committed by Vladimir Sukharev
parent 4786c945d9
commit b7fbfb2fde
10 changed files with 38 additions and 81 deletions
@@ -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")
}