[Native][tests] Reduce test generators verbosity to avoid failing Check Repository Test as TC

This commit is contained in:
Dmitriy Dolovov
2021-11-10 23:54:25 +03:00
parent 5f25b66eec
commit 8c598a25fd
3 changed files with 14 additions and 74 deletions
@@ -13,19 +13,16 @@ import org.jetbrains.kotlin.konan.blackboxtest.group.ExtTestCaseGroupProvider
fun main() {
System.setProperty("java.awt.headless", "true")
runAndLogDuration("Generating external Kotlin/Native blackbox tests") {
generateTestGroupSuiteWithJUnit5 {
cleanTestGroup(
testsRoot = "native/tests-blackbox/ext-tests-gen",
testDataRoot = "compiler/testData"
generateTestGroupSuiteWithJUnit5 {
testGroup("native/tests-blackbox/ext-tests-gen", "compiler/testData") {
testClass<AbstractNativeBlackBoxTest>(
suiteTestClassName = "NativeExtBlackBoxTestGenerated",
annotations = listOf(
annotation(CustomNativeBlackBoxTestCaseGroupProvider::class.java, ExtTestCaseGroupProvider::class.java)
)
) {
testClass<AbstractNativeBlackBoxTest>(
suiteTestClassName = "NativeExtBlackBoxTestGenerated",
annotations = listOf(annotation(CustomNativeBlackBoxTestCaseGroupProvider::class.java, ExtTestCaseGroupProvider::class.java))
) {
model("codegen/box")
model("codegen/boxInline")
}
model("codegen/box")
model("codegen/boxInline")
}
}
}
@@ -11,13 +11,11 @@ import org.jetbrains.kotlin.konan.blackboxtest.AbstractNativeBlackBoxTest
fun main() {
System.setProperty("java.awt.headless", "true")
runAndLogDuration("Generating Kotlin/Native blackbox tests") {
generateTestGroupSuiteWithJUnit5 {
cleanTestGroup("native/tests-blackbox/tests-gen", "native/tests-blackbox/testData") {
testClass<AbstractNativeBlackBoxTest> {
model("samples")
model("samples2")
}
generateTestGroupSuiteWithJUnit5 {
testGroup("native/tests-blackbox/tests-gen", "native/tests-blackbox/testData") {
testClass<AbstractNativeBlackBoxTest> {
model("samples")
model("samples2")
}
}
}
@@ -1,55 +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.
*/
@file:Suppress("unused")
package org.jetbrains.kotlin.generators.tests
import org.jetbrains.kotlin.generators.TestGroup
import org.jetbrains.kotlin.generators.TestGroupSuite
import org.jetbrains.kotlin.konan.blackboxtest.util.getAbsoluteFile
import java.io.File
import kotlin.system.measureTimeMillis
/** Fully clean-up the tests root directory before generating new test classes. */
internal fun TestGroupSuite.cleanTestGroup(testsRoot: String, testDataRoot: String, init: TestGroup.() -> Unit) {
getAbsoluteFile(localPath = testsRoot).deleteRecursivelyWithLogging()
testGroup(testsRoot, testDataRoot, init = init)
}
internal fun runAndLogDuration(actionDescription: String, action: () -> Unit) {
println("$actionDescription...")
val duration = measureTimeMillis(action)
val seconds = duration / 1000
val millis = duration % 100
println(
buildString {
append(actionDescription)
append(" took ")
if (seconds > 0) append(seconds).append("s ")
append(millis).append("ms")
}
)
}
internal fun File.deleteRecursivelyWithLogging() {
if (exists()) {
walkBottomUp().forEach { entry ->
val message = when {
entry.isFile -> "File removed: $entry"
entry.isDirectory && entry == this -> {
// Don't report directories except for the root directory.
"Directory removed (recursively): $entry"
}
else -> null
}
entry.delete()
message?.let(::println)
}
}
}