LeoColman
04/14/2023, 5:42 PMintercept
inside a place that for some reason I don't have a suspension contextLeoColman
04/14/2023, 5:42 PMrunBlocking { execute(testCase)
executes too late.
runBlocking(ctx) { execute(testCase) }
deadlocks (I think) the executionLeoColman
04/14/2023, 5:43 PMEmil Kantis
04/14/2023, 5:44 PMrunTest
function?LeoColman
04/14/2023, 5:45 PMLeoColman
04/14/2023, 5:47 PMsam
04/16/2023, 10:19 PMLeoColman
04/17/2023, 7:28 PMrunTest
block, before the callback hell is unwrapped.LeoColman
04/17/2023, 7:28 PMsam
04/17/2023, 7:54 PMLeoColman
04/17/2023, 8:56 PMfun notMyFun(block: () -> Unit) {}
override suspend fun intercept(testCase: TestCase, execute: suspend (TestCase) -> TestResult): TestResult {
var result: TestResult? = null
notMyFun {
result = execute(testCase)
}
return result!!
}
LeoColman
04/17/2023, 8:56 PMnotMyFun
, which isn't suspendable and isn't inlinedsam
04/17/2023, 8:57 PMLeoColman
04/17/2023, 8:58 PMfun notMyFun(block: () -> Unit) {}
override suspend fun intercept(testCase: TestCase, execute: suspend (TestCase) -> TestResult): TestResult {
var result: TestResult? = null
notMyFun {
result = runBlocking { execute(testCase) }
}
return result!!
}
But it gets run after notMyFun
have already finishedLeoColman
04/17/2023, 8:58 PMfun notMyFun(block: () -> Unit) {}
override suspend fun intercept(testCase: TestCase, execute: suspend (TestCase) -> TestResult): TestResult {
val ctx = currentCoroutineContext()
var result: TestResult? = null
notMyFun {
result = runBlocking(ctx) { execute(testCase) }
}
return result!!
}
But this leaves me in a locked running stateLeoColman
04/17/2023, 9:08 PMoverride suspend fun intercept(spec: Spec, execute: suspend (Spec) -> Unit) {
notMyFun {
runBlocking { execute(spec) }
}
}
Interesting, on Spec it workedLeoColman
04/17/2023, 9:10 PMnotMyFun
anywayLeoColman
04/17/2023, 9:13 PMLeoColman
04/17/2023, 9:13 PM