Skip to content

Commit 0ae7867

Browse files
Merge pull request #817 from square/coroutines_1.6
Upgrade coroutines to 1.6.4 (including coroutines.test changes)
2 parents d19ae7a + 58d2cc2 commit 0ae7867

File tree

23 files changed

+205
-198
lines changed

23 files changed

+205
-198
lines changed

gradle/libs.versions.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ kotest = "5.1.0"
4949
kotlin = "1.6.10"
5050

5151
kotlinx-binary-compatibility = "0.6.0"
52-
kotlinx-coroutines = "1.5.1"
53-
# The 1.5.1 test artifact is jvm-only. The commonTest module should use 1.6.1.
54-
kotlinx-coroutines-test-common = "1.6.1"
52+
kotlinx-coroutines = "1.6.4"
5553
kotlinx-serialization-json = "1.3.2"
5654
kotlinx-benchmark = "0.4.2"
5755
kotlinx-atomicfu = "0.17.2"
@@ -187,7 +185,7 @@ kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutine
187185
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" }
188186
kotlinx-coroutines-rx2 = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-rx2", version.ref = "kotlinx-coroutines" }
189187
kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinx-coroutines" }
190-
kotlinx-coroutines-test-common = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinx-coroutines-test-common" }
188+
kotlinx-coroutines-test-common = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinx-coroutines" }
191189
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinx-serialization-json" }
192190
kotlinx-benchmark-gradle-plugin = { module = "org.jetbrains.kotlinx:kotlinx-benchmark-plugin", version.ref = "kotlinx-benchmark" }
193191
kotlinx-benchmark-runtime = { module = "org.jetbrains.kotlinx:kotlinx-benchmark-runtime", version.ref = "kotlinx-benchmark" }

trace-encoder/dependencies/runtimeClasspath.txt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ com.squareup.moshi:moshi-adapters:1.13.0
22
com.squareup.moshi:moshi:1.13.0
33
com.squareup.okio:okio:2.10.0
44
org.jetbrains.kotlin:kotlin-bom:1.6.10
5-
org.jetbrains.kotlin:kotlin-stdlib-common:1.6.10
6-
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.10
7-
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.10
8-
org.jetbrains.kotlin:kotlin-stdlib:1.6.10
9-
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.5.1
10-
org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1
5+
org.jetbrains.kotlin:kotlin-stdlib-common:1.6.21
6+
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21
7+
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21
8+
org.jetbrains.kotlin:kotlin-stdlib:1.6.21
9+
org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.6.4
10+
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4
11+
org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4
1112
org.jetbrains:annotations:13.0

workflow-config/config-android/dependencies/releaseRuntimeClasspath.txt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
com.squareup.okio:okio-jvm:3.0.0
44
com.squareup.okio:okio:3.0.0
55
org.jetbrains.kotlin:kotlin-bom:1.6.10
6-
org.jetbrains.kotlin:kotlin-stdlib-common:1.6.10
7-
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.10
8-
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.10
9-
org.jetbrains.kotlin:kotlin-stdlib:1.6.10
10-
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.5.1
11-
org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1
6+
org.jetbrains.kotlin:kotlin-stdlib-common:1.6.21
7+
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21
8+
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21
9+
org.jetbrains.kotlin:kotlin-stdlib:1.6.21
10+
org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.6.4
11+
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4
12+
org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4
1213
org.jetbrains:annotations:13.0

workflow-config/config-jvm/dependencies/runtimeClasspath.txt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
com.squareup.okio:okio-jvm:3.0.0
44
com.squareup.okio:okio:3.0.0
55
org.jetbrains.kotlin:kotlin-bom:1.6.10
6-
org.jetbrains.kotlin:kotlin-stdlib-common:1.6.10
7-
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.10
8-
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.10
9-
org.jetbrains.kotlin:kotlin-stdlib:1.6.10
10-
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.5.1
11-
org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1
6+
org.jetbrains.kotlin:kotlin-stdlib-common:1.6.21
7+
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21
8+
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21
9+
org.jetbrains.kotlin:kotlin-stdlib:1.6.21
10+
org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.6.4
11+
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4
12+
org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4
1213
org.jetbrains:annotations:13.0
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
com.squareup.okio:okio-jvm:3.0.0
22
com.squareup.okio:okio:3.0.0
33
org.jetbrains.kotlin:kotlin-bom:1.6.10
4-
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.10
5-
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.10
6-
org.jetbrains.kotlin:kotlin-stdlib:1.6.10
7-
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.5.1
8-
org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1
4+
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21
5+
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21
6+
org.jetbrains.kotlin:kotlin-stdlib:1.6.21
7+
org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.6.4
8+
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4
9+
org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4
910
org.jetbrains:annotations:13.0
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
com.squareup.okio:okio-jvm:3.0.0
22
com.squareup.okio:okio:3.0.0
33
org.jetbrains.kotlin:kotlin-bom:1.6.10
4-
org.jetbrains.kotlin:kotlin-stdlib-common:1.6.10
5-
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.10
6-
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.10
7-
org.jetbrains.kotlin:kotlin-stdlib:1.6.10
8-
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.5.1
9-
org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1
4+
org.jetbrains.kotlin:kotlin-stdlib-common:1.6.21
5+
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21
6+
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21
7+
org.jetbrains.kotlin:kotlin-stdlib:1.6.21
8+
org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.6.4
9+
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4
10+
org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4
1011
org.jetbrains:annotations:13.0

workflow-runtime/dependencies/jvmRuntimeClasspath.txt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
com.squareup.okio:okio-jvm:3.0.0
33
com.squareup.okio:okio:3.0.0
44
org.jetbrains.kotlin:kotlin-bom:1.6.10
5-
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.10
6-
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.10
7-
org.jetbrains.kotlin:kotlin-stdlib:1.6.10
8-
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.5.1
9-
org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1
5+
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21
6+
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21
7+
org.jetbrains.kotlin:kotlin-stdlib:1.6.21
8+
org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.6.4
9+
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4
10+
org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4
1011
org.jetbrains:annotations:13.0

workflow-runtime/src/commonTest/kotlin/com/squareup/workflow1/RenderWorkflowInTest.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ class RenderWorkflowInTest {
215215
if (runtimeConfig1 is FrameTimeout) {
216216
// Get past frame timeout to ensure snapshot saved.
217217
testScope.advanceTimeBy(runtimeConfig1.frameTimeoutMs + 1)
218+
testScope.runCurrent()
218219
}
219220
val snapshot = renderings.value.let { (rendering, snapshot) ->
220221
val (state, updateState) = rendering
@@ -280,13 +281,15 @@ class RenderWorkflowInTest {
280281
if (runtimeConfig is FrameTimeout) {
281282
// Get past frame timeout to ensure snapshot saved.
282283
testScope.advanceTimeBy(runtimeConfig.frameTimeoutMs + 1)
284+
testScope.runCurrent()
283285
}
284286

285287
sink.send("unchanging state")
286288

287289
if (runtimeConfig is FrameTimeout) {
288290
// Get past frame timeout to ensure snapshot saved.
289291
testScope.advanceTimeBy(runtimeConfig.frameTimeoutMs + 1)
292+
testScope.runCurrent()
290293
}
291294

292295
scope.cancel()
@@ -506,6 +509,7 @@ class RenderWorkflowInTest {
506509
trigger.complete(Unit)
507510
if (runtimeConfig is FrameTimeout) {
508511
testScope.advanceTimeBy(runtimeConfig.frameTimeoutMs + 1)
512+
testScope.runCurrent()
509513
}
510514
assertFalse(testScope.isActive)
511515
}

workflow-runtime/src/commonTest/kotlin/com/squareup/workflow1/internal/WorkflowNodeTest.kt

Lines changed: 31 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@file:Suppress("EXPERIMENTAL_API_USAGE", "DEPRECATION")
2+
@file:OptIn(ExperimentalCoroutinesApi::class)
23

34
package com.squareup.workflow1.internal
45

@@ -29,12 +30,13 @@ import kotlinx.coroutines.CancellationException
2930
import kotlinx.coroutines.CoroutineName
3031
import kotlinx.coroutines.CoroutineScope
3132
import kotlinx.coroutines.Dispatchers.Unconfined
33+
import kotlinx.coroutines.ExperimentalCoroutinesApi
3234
import kotlinx.coroutines.Job
3335
import kotlinx.coroutines.cancel
3436
import kotlinx.coroutines.flow.MutableStateFlow
35-
import kotlinx.coroutines.runBlocking
3637
import kotlinx.coroutines.selects.select
3738
import kotlinx.coroutines.suspendCancellableCoroutine
39+
import kotlinx.coroutines.test.runTest
3840
import kotlinx.coroutines.withTimeout
3941
import kotlin.coroutines.CoroutineContext
4042
import kotlin.test.AfterTest
@@ -173,14 +175,14 @@ internal class WorkflowNodeTest {
173175
)
174176
node.render(workflow, "")("event")
175177

176-
val result = runBlocking {
177-
withTimeout(10) {
178+
runTest {
179+
val result = withTimeout(10) {
178180
select<ActionProcessingResult?> {
179181
node.tick(this)
180182
} as WorkflowOutput<String>?
181183
}
184+
assertEquals("tick:event", result?.value)
182185
}
183-
assertEquals("tick:event", result?.value)
184186
}
185187

186188
@Test fun `accepts events sent to stale renderings`() {
@@ -210,16 +212,16 @@ internal class WorkflowNodeTest {
210212
sink("event")
211213
sink("event2")
212214

213-
val result = runBlocking {
214-
withTimeout(10) {
215+
runTest {
216+
val result = withTimeout(10) {
215217
List(2) {
216218
select<ActionProcessingResult?> {
217219
node.tick(this)
218220
} as WorkflowOutput<String>?
219221
}
220222
}
223+
assertEquals(listOf("tick:event", "tick:event2"), result.map { it?.value })
221224
}
222-
assertEquals(listOf("tick:event", "tick:event2"), result.map { it?.value })
223225
}
224226

225227
@Test fun `send allows subsequent events on same rendering`() {
@@ -264,7 +266,7 @@ internal class WorkflowNodeTest {
264266
snapshot = null, baseContext = context
265267
)
266268

267-
runBlocking {
269+
runTest {
268270
node.render(workflow.asStatefulWorkflow(), Unit)
269271
assertTrue(started)
270272
}
@@ -302,16 +304,15 @@ internal class WorkflowNodeTest {
302304
)
303305
node.render(workflow.asStatefulWorkflow(), Unit)
304306

305-
val result = runBlocking {
307+
runTest {
306308
// Result should be available instantly, any delay at all indicates something is broken.
307-
withTimeout(1) {
309+
val result = withTimeout(1) {
308310
select<ActionProcessingResult?> {
309311
node.tick(this)
310312
} as WorkflowOutput<String>?
311313
}
314+
assertEquals("result", result?.value)
312315
}
313-
314-
assertEquals("result", result?.value)
315316
}
316317

317318
@Test fun `sideEffect is cancelled when stops being ran`() {
@@ -331,7 +332,7 @@ internal class WorkflowNodeTest {
331332
snapshot = null, baseContext = context
332333
)
333334

334-
runBlocking {
335+
runTest {
335336
node.render(workflow.asStatefulWorkflow(), true)
336337
assertNull(cancellationException)
337338

@@ -357,7 +358,7 @@ internal class WorkflowNodeTest {
357358
snapshot = null, baseContext = context
358359
)
359360

360-
runBlocking {
361+
runTest {
361362
node.render(workflow.asStatefulWorkflow(), Unit)
362363
assertNull(cancellationException)
363364

@@ -383,7 +384,7 @@ internal class WorkflowNodeTest {
383384
snapshot = null, baseContext = context
384385
)
385386

386-
runBlocking {
387+
runTest {
387388
node.render(workflow.asStatefulWorkflow(), 0)
388389
assertFalse(cancelled)
389390
assertEquals(1, renderPasses)
@@ -408,7 +409,7 @@ internal class WorkflowNodeTest {
408409
snapshot = null, baseContext = context
409410
)
410411

411-
runBlocking {
412+
runTest {
412413
node.render(workflow.asStatefulWorkflow(), 0)
413414
assertEquals(listOf(0), seenProps)
414415
assertEquals(1, renderPasses)
@@ -1099,7 +1100,7 @@ internal class WorkflowNodeTest {
10991100

11001101
sink.send("hello")
11011102

1102-
runBlocking {
1103+
runTest {
11031104
select<ActionProcessingResult?> {
11041105
node.tick(this)
11051106
} as WorkflowOutput<String>?
@@ -1125,13 +1126,12 @@ internal class WorkflowNodeTest {
11251126

11261127
rendering.send("hello")
11271128

1128-
val output = runBlocking {
1129-
select<ActionProcessingResult?> {
1129+
runTest {
1130+
val output = select<ActionProcessingResult?> {
11301131
node.tick(this)
11311132
} as WorkflowOutput<String>?
1133+
assertEquals("output:hello", output?.value)
11321134
}
1133-
1134-
assertEquals("output:hello", output?.value)
11351135
}
11361136

11371137
@Test fun `actionSink action allows null output`() {
@@ -1150,13 +1150,12 @@ internal class WorkflowNodeTest {
11501150

11511151
rendering.send("hello")
11521152

1153-
val output = runBlocking {
1154-
select<ActionProcessingResult?> {
1153+
runTest {
1154+
val output = select<ActionProcessingResult?> {
11551155
node.tick(this)
11561156
} as WorkflowOutput<String>?
1157+
assertNull(output?.value)
11571158
}
1158-
1159-
assertNull(output?.value)
11601159
}
11611160

11621161
@Test fun `child action changes state`() {
@@ -1178,7 +1177,7 @@ internal class WorkflowNodeTest {
11781177
)
11791178
node.render(workflow.asStatefulWorkflow(), Unit)
11801179

1181-
runBlocking {
1180+
runTest {
11821181
select<ActionProcessingResult?> {
11831182
node.tick(this)
11841183
} as WorkflowOutput<String>?
@@ -1204,13 +1203,12 @@ internal class WorkflowNodeTest {
12041203
)
12051204
node.render(workflow.asStatefulWorkflow(), Unit)
12061205

1207-
val output = runBlocking {
1208-
select<ActionProcessingResult?> {
1206+
runTest {
1207+
val output = select<ActionProcessingResult?> {
12091208
node.tick(this)
12101209
} as WorkflowOutput<String>?
1210+
assertEquals("output:child:hello", output?.value)
12111211
}
1212-
1213-
assertEquals("output:child:hello", output?.value)
12141212
}
12151213

12161214
@Test fun `child action allows null output`() {
@@ -1229,13 +1227,12 @@ internal class WorkflowNodeTest {
12291227
)
12301228
node.render(workflow.asStatefulWorkflow(), Unit)
12311229

1232-
val output = runBlocking {
1233-
select<ActionProcessingResult?> {
1230+
runTest {
1231+
val output = select<ActionProcessingResult?> {
12341232
node.tick(this)
12351233
} as WorkflowOutput<String>?
1234+
assertNull(output?.value)
12361235
}
1237-
1238-
assertNull(output?.value)
12391236
}
12401237

12411238
private class TestSession(override val sessionId: Long = 0) : WorkflowSession {

workflow-rx2/dependencies/runtimeClasspath.txt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ com.squareup.okio:okio-jvm:3.0.0
33
com.squareup.okio:okio:3.0.0
44
io.reactivex.rxjava2:rxjava:2.2.21
55
org.jetbrains.kotlin:kotlin-bom:1.6.10
6-
org.jetbrains.kotlin:kotlin-stdlib-common:1.6.10
7-
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.10
8-
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.10
9-
org.jetbrains.kotlin:kotlin-stdlib:1.6.10
10-
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.5.1
11-
org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1
12-
org.jetbrains.kotlinx:kotlinx-coroutines-reactive:1.5.1
13-
org.jetbrains.kotlinx:kotlinx-coroutines-rx2:1.5.1
6+
org.jetbrains.kotlin:kotlin-stdlib-common:1.6.21
7+
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21
8+
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21
9+
org.jetbrains.kotlin:kotlin-stdlib:1.6.21
10+
org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.6.4
11+
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4
12+
org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4
13+
org.jetbrains.kotlinx:kotlinx-coroutines-reactive:1.6.4
14+
org.jetbrains.kotlinx:kotlinx-coroutines-rx2:1.6.4
1415
org.jetbrains:annotations:13.0
1516
org.reactivestreams:reactive-streams:1.0.3

0 commit comments

Comments
 (0)