Skip to content

Commit 0ff1625

Browse files
committed
Kotlin 1.5 workaround
1 parent b39097e commit 0ff1625

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

kotest-framework/kotest-framework-engine/src/commonMain/kotlin/io/kotest/engine/test/TestInvocationInterceptor.kt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import io.kotest.engine.test.interceptors.TestExecutionInterceptor
88
import io.kotest.mpp.Logger
99
import io.kotest.mpp.replay
1010
import kotlinx.coroutines.coroutineScope
11+
import kotlin.time.Duration
1112
import kotlin.time.TimeMark
1213

1314
class TestInvocationInterceptor(
@@ -36,10 +37,18 @@ class TestInvocationInterceptor(
3637
}
3738
}
3839
logger.log { Pair(testCase.name.testName, "Test returned without error") }
39-
TestResult.Success(timeMark.elapsedNow())
40+
try {
41+
TestResult.Success(timeMark.elapsedNow())
42+
} catch (e: Exception) {
43+
TestResult.Success(Duration.ZERO) // kotlin 1.5 workaround
44+
}
4045
} catch (t: Throwable) {
4146
logger.log { Pair(testCase.name.testName, "Test threw error $t") }
42-
createTestResult(timeMark.elapsedNow(), t)
47+
try {
48+
TestResult.Success(timeMark.elapsedNow())
49+
} catch (e: Exception) {
50+
TestResult.Error(Duration.ZERO, t) // kotlin 1.5 workaround
51+
}
4352
}
4453
}
4554
}

0 commit comments

Comments
 (0)