-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feature/GH-29-improve-exception-conversion
- Loading branch information
Showing
6 changed files
with
67 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
...coroutines-core/src/appleTest/kotlin/com/rickclephas/kmp/nativecoroutines/RunTestApple.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.rickclephas.kmp.nativecoroutines | ||
|
||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.Job | ||
import kotlinx.coroutines.runBlocking | ||
import kotlin.coroutines.CoroutineContext | ||
|
||
@Suppress("ACTUAL_WITHOUT_EXPECT") | ||
actual typealias TestResult = Unit | ||
|
||
internal actual fun runTest( | ||
context: CoroutineContext, | ||
block: suspend CoroutineScope.() -> Unit | ||
): TestResult = runBlocking(context, block) | ||
|
||
@Suppress("SuspendFunctionOnCoroutineScope") | ||
internal actual suspend fun CoroutineScope.runCurrent() { | ||
coroutineContext[Job]?.children?.forEach { it.join() } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...ines-core/src/nativeCoroutinesTest/kotlin/com/rickclephas/kmp/nativecoroutines/RunTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.rickclephas.kmp.nativecoroutines | ||
|
||
import kotlinx.coroutines.CoroutineScope | ||
import kotlin.coroutines.CoroutineContext | ||
import kotlin.coroutines.EmptyCoroutineContext | ||
|
||
@Suppress("NO_ACTUAL_FOR_EXPECT") | ||
expect class TestResult | ||
|
||
/** | ||
* There is a freezing [issue](https://github.com/Kotlin/kotlinx.coroutines/issues/3195) | ||
* with the [kotlinx.coroutines.test.runTest] function. | ||
* | ||
* As a temporary workaround this function uses `runBlocking` on native targets instead. | ||
* This is kind of hacky, but once we drop the old memory model this is no longer needed. | ||
*/ | ||
// TODO: Remove temporary fix for runTest freezing issue | ||
internal expect fun runTest( | ||
context: CoroutineContext = EmptyCoroutineContext, | ||
block: suspend CoroutineScope.() -> Unit | ||
): TestResult | ||
|
||
internal expect suspend fun CoroutineScope.runCurrent() |