Add ability to skip stats for performance tests if there is a custom stats name

This commit is contained in:
Vladimir Dolzhenko
2020-06-06 22:01:54 +02:00
parent bd2a0563ad
commit 0f73cdeccb
2 changed files with 5 additions and 5 deletions
@@ -59,7 +59,7 @@ class Stats(
)) {
val n = "$id : ${v.first}"
TeamCity.test(n, durationMs = v.third) {
TeamCity.test(n, durationMs = v.third, includeStats = false) {
TeamCity.statValue("$id${v.second}", v.third)
}
}
@@ -78,7 +78,7 @@ class Stats(
val shortName = if (perfCounterName.endsWith(": time")) n.removeSuffix(": time") else null
shortName?.let {
TeamCity.test(it, durationMs = mean) {
TeamCity.test(it, durationMs = mean, includeStats = false) {
TeamCity.statValue(it, mean)
}
}
@@ -39,15 +39,15 @@ object TeamCity {
}
fun test(name: String, durationMs: Long? = null, errors: List<Throwable>, block: () -> Unit) {
test(name, durationMs, if (errors.isNotEmpty()) toDetails(errors) else null, block)
test(name, durationMs, errorDetails = if (errors.isNotEmpty()) toDetails(errors) else null, block = block)
}
fun test(name: String, durationMs: Long? = null, errorDetails: String? = null, block: () -> Unit) {
fun test(name: String, durationMs: Long? = null, includeStats: Boolean = true, errorDetails: String? = null, block: () -> Unit) {
testStarted(name)
try {
block()
} finally {
statValue(name, durationMs ?: -1)
if (includeStats) statValue(name, durationMs ?: -1)
if (errorDetails != null) {
testFailed(name, errorDetails)
} else {