From b4dcf45ffa6eb1190733c2daf8d7487a71a6b984 Mon Sep 17 00:00:00 2001 From: Pavel Punegov Date: Thu, 29 Apr 2021 14:23:34 +0300 Subject: [PATCH] [Native][Tests] Improve reporting for external codegen tests Add abort() method that adds tests that failed to compile to statistics with Error status. --- .../main/groovy/org/jetbrains/kotlin/KonanTest.groovy | 4 ++-- .../org/jetbrains/kotlin/KonanTestSuiteReport.kt | 11 ++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/kotlin-native/build-tools/src/main/groovy/org/jetbrains/kotlin/KonanTest.groovy b/kotlin-native/build-tools/src/main/groovy/org/jetbrains/kotlin/KonanTest.groovy index 95822b8b25d..4c507102489 100644 --- a/kotlin-native/build-tools/src/main/groovy/org/jetbrains/kotlin/KonanTest.groovy +++ b/kotlin-native/build-tools/src/main/groovy/org/jetbrains/kotlin/KonanTest.groovy @@ -553,8 +553,8 @@ fun runTest() { project.logger.quiet("ERROR: Compilation failed for test suite: $name with exception", ex) project.logger.quiet("The following files were unable to compile:") ktFiles.each { project.logger.quiet(it.name) } - suite.abort(ex, ktFiles.size()) - throw new RuntimeException("Compilation failed", ex) + suite.abort("Compilation failed for test suite: $name", ex, ktFiles.collect { it.name }) + return } // Run the tests. diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/KonanTestSuiteReport.kt b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/KonanTestSuiteReport.kt index b6923007498..66f13ee5b25 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/KonanTestSuiteReport.kt +++ b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/KonanTestSuiteReport.kt @@ -83,7 +83,16 @@ class KonanTestSuiteReportEnvironment(val name: String, val project: Project, va tests += KonanTestCaseReport(name, TestStatus.SKIPPED) } - fun abort(throwable: Throwable, count:Int) { + fun abort(comment: String, throwable: Throwable, testNames: List) { + testNames.forEach { + tc?.startTest(it) + tc?.errorTest(it, java.lang.Exception(throwable)) + tests += KonanTestCaseReport(it, TestStatus.ERROR, "$comment\n${throwable.toString()}") + } + abort(throwable, testNames.size) + } + + fun abort(throwable: Throwable, count: Int) { statistics.error(count) project.logger.quiet("suite `$name` aborted with exception", throwable) }