[K/N][Tests] Cleanup support code for objCFrameworks in old testinfra
^KT-61259
This commit is contained in:
committed by
Space Team
parent
a4854cf81f
commit
6c78ec88c2
@@ -123,8 +123,6 @@ allprojects {
|
||||
|
||||
// backend.native/tests/framework
|
||||
ext.testOutputFramework = rootProject.file("$testOutputRoot/framework")
|
||||
|
||||
ext.testOutputFileCheck = rootProject.file("$testOutputRoot/filecheck")
|
||||
}
|
||||
testOutputExternal.mkdirs()
|
||||
|
||||
@@ -177,7 +175,6 @@ tasks.named("clean", Delete.class) {
|
||||
|
||||
tasks.named("run") {
|
||||
dependsOn(tasks.withType(KonanTest).matching { it.enabled })
|
||||
dependsOn(tasks.withType(FileCheckTest).matching { it.enabled })
|
||||
// Add regular gradle test tasks
|
||||
dependsOn(tasks.withType(Test).matching { it.enabled })
|
||||
// TODO(KTI-1571): This task should be run by Compiler Unit Tests (Native) configuration
|
||||
@@ -1950,71 +1947,6 @@ pluginTest("runtime_basic_init", "nopPlugin") {
|
||||
flags = ["-tr"]
|
||||
}
|
||||
|
||||
|
||||
Task fileCheckTest(String name, Closure<FileCheckTest> configureClosure) {
|
||||
return project.tasks.create(name, FileCheckTest) { FileCheckTest task ->
|
||||
task.configure(configureClosure)
|
||||
task.llvmIr = project.file("$testOutputFileCheck/$name/$target/out.${task.phaseToCheck}.ll")
|
||||
|
||||
KonanTarget target = task.target
|
||||
boolean isCrossCompiling = target != project.target
|
||||
|
||||
// Bitcode that is generated in presence of caches or two-stage compilation differs from the "closed world"-generated,
|
||||
// so disable these tests for now.
|
||||
if (task.enabled && twoStageEnabled)
|
||||
task.enabled = false
|
||||
|
||||
if (task.enabled) {
|
||||
konanArtifacts {
|
||||
def lib = task.interop
|
||||
if (lib != null) {
|
||||
UtilsKt.dependsOnKonanBuildingTask(task, lib, target)
|
||||
}
|
||||
if (!task.generateFramework) {
|
||||
// We could use `bitcode` here to make things faster. But:
|
||||
// 1. `bitcode` has no other usages.
|
||||
// 2. Unification should help porting to the new test infra.
|
||||
// 3. Compiler might behave differently when outputting bitcode instead of object files.
|
||||
program(name, targets: [target]) {
|
||||
srcFiles task.annotatedSource
|
||||
baseDir "$testOutputFileCheck/$name"
|
||||
if (!isCrossCompiling) {
|
||||
extraOpts project.globalTestArgs
|
||||
}
|
||||
extraOpts task.extraOpts
|
||||
extraOpts "-Xsave-llvm-ir-directory=$testOutputFileCheck/$name/$target"
|
||||
extraOpts "-Xsave-llvm-ir-after=${task.phaseToCheck}"
|
||||
if (lib != null) {
|
||||
libraries {
|
||||
artifact lib
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Framework support is much weakier than `frameworkTest`, but we don't need much.
|
||||
framework(name, targets: [target]) {
|
||||
srcFiles task.annotatedSource
|
||||
baseDir "$testOutputFileCheck/$name"
|
||||
if (!isCrossCompiling) {
|
||||
extraOpts project.globalTestArgs
|
||||
}
|
||||
extraOpts "-Xsave-llvm-ir-directory=$testOutputFileCheck/$name/$target"
|
||||
extraOpts "-Xsave-llvm-ir-after=${task.phaseToCheck}"
|
||||
|
||||
if (lib != null) {
|
||||
libraries {
|
||||
artifact lib
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
UtilsKt.dependsOnKonanBuildingTask(task, name, target)
|
||||
}
|
||||
task.dependsOn(nativeDependencies.llvmDependency)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
nopPluginApi kotlinCompilerModule
|
||||
nopPluginApi project(":native:kotlin-native-utils")
|
||||
|
||||
@@ -1,123 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2021 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
|
||||
|
||||
import groovy.lang.Closure
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.Task
|
||||
import org.gradle.api.tasks.*
|
||||
import org.jetbrains.kotlin.konan.target.*
|
||||
import java.io.File
|
||||
import java.nio.file.Path
|
||||
|
||||
/**
|
||||
* Gradle task that wraps FileCheck LLVM utility.
|
||||
*/
|
||||
open class FileCheckTest : DefaultTask() {
|
||||
/**
|
||||
* File annotated with FileCheck directives.
|
||||
*/
|
||||
@InputFile
|
||||
lateinit var annotatedSource: File
|
||||
|
||||
/**
|
||||
* LLVM IR that should match [annotatedSource].
|
||||
*/
|
||||
@get:Internal
|
||||
lateinit var llvmIr: File
|
||||
|
||||
/**
|
||||
* Optional cinterop task dependency.
|
||||
*/
|
||||
@get:Optional
|
||||
@get:Input
|
||||
var interop: String? = null
|
||||
|
||||
@TaskAction
|
||||
fun run() {
|
||||
runFileCheck(annotatedSource.toPath(), llvmIr.toPath())
|
||||
}
|
||||
|
||||
/**
|
||||
* What prefix should checked for pattern instead of default CHECK?
|
||||
*/
|
||||
@get:Input
|
||||
@get:Optional
|
||||
var checkPrefix: String? = null
|
||||
|
||||
/**
|
||||
* Compiler pipeline phase name, after which check should be done
|
||||
*/
|
||||
@get:Input
|
||||
var phaseToCheck: String = "CStubs"
|
||||
|
||||
/**
|
||||
* Should we generate framework instead of an executable?
|
||||
* This option is useful for, well, checking framework-specific code.
|
||||
*/
|
||||
@get:Input
|
||||
var generateFramework: Boolean = false
|
||||
|
||||
@get:Input
|
||||
@get:Optional
|
||||
var additionalFileCheckFlags: List<String>? = null
|
||||
|
||||
@get:Input
|
||||
var extraOpts: List<String> = emptyList()
|
||||
|
||||
@get:Optional
|
||||
@get:Input
|
||||
var targetName: String = project.testTarget.name
|
||||
|
||||
@get:Internal
|
||||
val target: KonanTarget
|
||||
get() = project.platformManager.targetByName(targetName)
|
||||
|
||||
override fun configure(closure: Closure<*>): Task {
|
||||
super.configure(closure)
|
||||
if (target != HostManager.host) {
|
||||
dependsOnCrossDist(target)
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that [inputFile] matches [annotatedFile] with FileCheck.
|
||||
*/
|
||||
private fun runFileCheck(annotatedFile: Path, inputFile: Path): ProcessOutput {
|
||||
val args = mutableListOf(
|
||||
annotatedFile.toAbsolutePath().toString(),
|
||||
"--input-file", inputFile.toAbsolutePath().toString()
|
||||
)
|
||||
checkPrefix?.let {
|
||||
args.addAll(listOf("--check-prefix", it))
|
||||
}
|
||||
additionalFileCheckFlags?.let {
|
||||
args.addAll(it)
|
||||
}
|
||||
val platform = project.platformManager.platform(target)
|
||||
val configurables = platform.configurables
|
||||
val llvmBin = "${configurables.absoluteLlvmHome}/bin"
|
||||
val fileCheck = "$llvmBin/FileCheck"
|
||||
return runProcess(localExecutor(project), fileCheck, *args.toTypedArray())
|
||||
.ensureSuccessful(fileCheck, *args.toTypedArray())
|
||||
}
|
||||
|
||||
private fun ProcessOutput.ensureSuccessful(vararg command: String): ProcessOutput {
|
||||
if (exitCode != 0) {
|
||||
println("""
|
||||
${command.joinToString(separator = " ")} failed.
|
||||
exitCode: $exitCode
|
||||
stdout:
|
||||
$stdOut
|
||||
stderr:
|
||||
$stdErr
|
||||
""".trimIndent())
|
||||
throw TestFailedException("${command.joinToString(separator = " ")} failed")
|
||||
}
|
||||
return this
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user