[Native] Improve skipped and filed tests reporting in GTestLogger
List skipped tests appropriately like the GTest does
This commit is contained in:
@@ -187,6 +187,9 @@ open class KonanGTest : KonanTest() {
|
|||||||
|
|
||||||
Pattern.compile("\\[ FAILED ] ([0-9]*) tests.*").matcher(output)
|
Pattern.compile("\\[ FAILED ] ([0-9]*) tests.*").matcher(output)
|
||||||
.apply { if (find()) fail(group(1).toInt()) }
|
.apply { if (find()) fail(group(1).toInt()) }
|
||||||
|
|
||||||
|
Pattern.compile("\\[ SKIPPED ] ([0-9]*) test.*").matcher(output)
|
||||||
|
.apply { if (find()) skip(group(1).toInt()) }
|
||||||
if (total == 0) {
|
if (total == 0) {
|
||||||
// No test were run. Try to find if we've tried to run something
|
// No test were run. Try to find if we've tried to run something
|
||||||
error(Pattern.compile("\\[={10}] Running ([0-9]*) tests from ([0-9]*) test cases\\..*")
|
error(Pattern.compile("\\[={10}] Running ([0-9]*) tests from ([0-9]*) test cases\\..*")
|
||||||
|
|||||||
@@ -27,15 +27,20 @@ internal class GTestLogger : TestLoggerWithStatistics() {
|
|||||||
println("[----------] Global test environment tear-down") // Just hack to deal with GTest output parsers.
|
println("[----------] Global test environment tear-down") // Just hack to deal with GTest output parsers.
|
||||||
println("[==========] $total tests from $totalSuites test cases ran. ($timeMillis ms total)")
|
println("[==========] $total tests from $totalSuites test cases ran. ($timeMillis ms total)")
|
||||||
println("[ PASSED ] $passed tests.")
|
println("[ PASSED ] $passed tests.")
|
||||||
|
if (ignored != 0) {
|
||||||
|
val testsAmount = if (ignored == 1) "1 test" else "$ignored tests"
|
||||||
|
println("[ SKIPPED ] $testsAmount, listed below:")
|
||||||
|
ignoredTests.forEach {
|
||||||
|
println("[ SKIPPED ] ${it.prettyName}")
|
||||||
|
}
|
||||||
|
}
|
||||||
if (hasFailedTests) {
|
if (hasFailedTests) {
|
||||||
println("[ FAILED ] $failed tests, listed below:")
|
val testsForm = if (failed == 1) "test" else "tests"
|
||||||
|
println("[ FAILED ] $failed $testsForm, listed below:")
|
||||||
failedTests.forEach {
|
failedTests.forEach {
|
||||||
println("[ FAILED ] ${it.prettyName}")
|
println("[ FAILED ] ${it.prettyName}")
|
||||||
}
|
}
|
||||||
println("\n$failed FAILED TESTS")
|
println("\n$failed FAILED ${testsForm.uppercase()}")
|
||||||
}
|
|
||||||
if (ignored != 0) {
|
|
||||||
println("YOU HAVE $ignored DISABLED TEST(S)")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,10 +30,10 @@ internal open class TestLoggerWithStatistics: BaseTestLogger() {
|
|||||||
override fun startIteration(runner: TestRunner, iteration: Int, suites: Collection<TestSuite>) = statistics.reset()
|
override fun startIteration(runner: TestRunner, iteration: Int, suites: Collection<TestSuite>) = statistics.reset()
|
||||||
|
|
||||||
override fun finishSuite(suite: TestSuite, timeMillis: Long) = statistics.registerSuite()
|
override fun finishSuite(suite: TestSuite, timeMillis: Long) = statistics.registerSuite()
|
||||||
override fun ignoreSuite(suite: TestSuite) = statistics.registerIgnore(suite.size)
|
override fun ignoreSuite(suite: TestSuite) = statistics.registerIgnore(suite)
|
||||||
override fun pass(testCase: TestCase, timeMillis: Long) = statistics.registerPass()
|
override fun pass(testCase: TestCase, timeMillis: Long) = statistics.registerPass()
|
||||||
override fun fail(testCase: TestCase, e: Throwable, timeMillis: Long) = statistics.registerFail(testCase)
|
override fun fail(testCase: TestCase, e: Throwable, timeMillis: Long) = statistics.registerFail(testCase)
|
||||||
override fun ignore(testCase: TestCase) = statistics.registerIgnore()
|
override fun ignore(testCase: TestCase) = statistics.registerIgnore(testCase)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class SilentTestLogger: BaseTestLogger() {
|
internal class SilentTestLogger: BaseTestLogger() {
|
||||||
|
|||||||
+17
-6
@@ -21,7 +21,9 @@ internal class MutableTestStatistics: TestStatistics {
|
|||||||
|
|
||||||
override var total: Int = 0; private set
|
override var total: Int = 0; private set
|
||||||
override var passed: Int = 0; private set
|
override var passed: Int = 0; private set
|
||||||
override var ignored: Int = 0; private set
|
|
||||||
|
override val ignored: Int
|
||||||
|
get() = _ignoredTests.size
|
||||||
|
|
||||||
override var totalSuites: Int = 0; private set
|
override var totalSuites: Int = 0; private set
|
||||||
|
|
||||||
@@ -35,6 +37,10 @@ internal class MutableTestStatistics: TestStatistics {
|
|||||||
override val failedTests: Collection<TestCase>
|
override val failedTests: Collection<TestCase>
|
||||||
get() = _failedTests
|
get() = _failedTests
|
||||||
|
|
||||||
|
private val _ignoredTests = mutableListOf<TestCase>()
|
||||||
|
val ignoredTests: Collection<TestCase>
|
||||||
|
get() = _ignoredTests
|
||||||
|
|
||||||
fun registerSuite(count: Int = 1) {
|
fun registerSuite(count: Int = 1) {
|
||||||
require(count >= 0)
|
require(count >= 0)
|
||||||
totalSuites += count
|
totalSuites += count
|
||||||
@@ -53,17 +59,22 @@ internal class MutableTestStatistics: TestStatistics {
|
|||||||
|
|
||||||
fun registerFail(testCase: TestCase) = registerFail(listOf(testCase))
|
fun registerFail(testCase: TestCase) = registerFail(listOf(testCase))
|
||||||
|
|
||||||
fun registerIgnore(count: Int = 1) {
|
fun registerIgnore(testCases: Collection<TestCase>) {
|
||||||
require(count >= 0)
|
total += testCases.size
|
||||||
total += count
|
_ignoredTests.addAll(testCases)
|
||||||
ignored += count
|
}
|
||||||
|
|
||||||
|
fun registerIgnore(testCase: TestCase) = registerIgnore(listOf(testCase))
|
||||||
|
|
||||||
|
fun registerIgnore(suite: TestSuite) {
|
||||||
|
registerIgnore(suite.testCases.values)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun reset() {
|
fun reset() {
|
||||||
total = 0
|
total = 0
|
||||||
passed = 0
|
passed = 0
|
||||||
ignored = 0
|
|
||||||
totalSuites = 0
|
totalSuites = 0
|
||||||
_failedTests.clear()
|
_failedTests.clear()
|
||||||
|
_ignoredTests.clear()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user