Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade coroutines to 1.6.4 (including coroutines.test changes) #817

Merged
merged 1 commit into from
Jul 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ kotest = "5.1.0"
kotlin = "1.6.10"

kotlinx-binary-compatibility = "0.6.0"
kotlinx-coroutines = "1.5.1"
# The 1.5.1 test artifact is jvm-only. The commonTest module should use 1.6.1.
kotlinx-coroutines-test-common = "1.6.1"
kotlinx-coroutines = "1.6.4"
kotlinx-serialization-json = "1.3.2"
kotlinx-benchmark = "0.4.2"
kotlinx-atomicfu = "0.17.2"
Expand Down Expand Up @@ -187,7 +185,7 @@ kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutine
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" }
kotlinx-coroutines-rx2 = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-rx2", version.ref = "kotlinx-coroutines" }
kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinx-coroutines" }
kotlinx-coroutines-test-common = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinx-coroutines-test-common" }
kotlinx-coroutines-test-common = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinx-coroutines" }
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinx-serialization-json" }
kotlinx-benchmark-gradle-plugin = { module = "org.jetbrains.kotlinx:kotlinx-benchmark-plugin", version.ref = "kotlinx-benchmark" }
kotlinx-benchmark-runtime = { module = "org.jetbrains.kotlinx:kotlinx-benchmark-runtime", version.ref = "kotlinx-benchmark" }
Expand Down
13 changes: 7 additions & 6 deletions trace-encoder/dependencies/runtimeClasspath.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ com.squareup.moshi:moshi-adapters:1.13.0
com.squareup.moshi:moshi:1.13.0
com.squareup.okio:okio:2.10.0
org.jetbrains.kotlin:kotlin-bom:1.6.10
org.jetbrains.kotlin:kotlin-stdlib-common:1.6.10
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.10
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.10
org.jetbrains.kotlin:kotlin-stdlib:1.6.10
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.5.1
org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1
org.jetbrains.kotlin:kotlin-stdlib-common:1.6.21
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21
org.jetbrains.kotlin:kotlin-stdlib:1.6.21
org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.6.4
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4
org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4
org.jetbrains:annotations:13.0
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
com.squareup.okio:okio-jvm:3.0.0
com.squareup.okio:okio:3.0.0
org.jetbrains.kotlin:kotlin-bom:1.6.10
org.jetbrains.kotlin:kotlin-stdlib-common:1.6.10
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.10
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.10
org.jetbrains.kotlin:kotlin-stdlib:1.6.10
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.5.1
org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1
org.jetbrains.kotlin:kotlin-stdlib-common:1.6.21
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21
org.jetbrains.kotlin:kotlin-stdlib:1.6.21
org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.6.4
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4
org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4
org.jetbrains:annotations:13.0
13 changes: 7 additions & 6 deletions workflow-config/config-jvm/dependencies/runtimeClasspath.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
com.squareup.okio:okio-jvm:3.0.0
com.squareup.okio:okio:3.0.0
org.jetbrains.kotlin:kotlin-bom:1.6.10
org.jetbrains.kotlin:kotlin-stdlib-common:1.6.10
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.10
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.10
org.jetbrains.kotlin:kotlin-stdlib:1.6.10
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.5.1
org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1
org.jetbrains.kotlin:kotlin-stdlib-common:1.6.21
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21
org.jetbrains.kotlin:kotlin-stdlib:1.6.21
org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.6.4
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4
org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4
org.jetbrains:annotations:13.0
11 changes: 6 additions & 5 deletions workflow-core/dependencies/jvmRuntimeClasspath.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
com.squareup.okio:okio-jvm:3.0.0
com.squareup.okio:okio:3.0.0
org.jetbrains.kotlin:kotlin-bom:1.6.10
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.10
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.10
org.jetbrains.kotlin:kotlin-stdlib:1.6.10
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.5.1
org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21
org.jetbrains.kotlin:kotlin-stdlib:1.6.21
org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.6.4
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4
org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4
org.jetbrains:annotations:13.0
13 changes: 7 additions & 6 deletions workflow-core/dependencies/runtimeClasspath.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
com.squareup.okio:okio-jvm:3.0.0
com.squareup.okio:okio:3.0.0
org.jetbrains.kotlin:kotlin-bom:1.6.10
org.jetbrains.kotlin:kotlin-stdlib-common:1.6.10
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.10
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.10
org.jetbrains.kotlin:kotlin-stdlib:1.6.10
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.5.1
org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1
org.jetbrains.kotlin:kotlin-stdlib-common:1.6.21
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21
org.jetbrains.kotlin:kotlin-stdlib:1.6.21
org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.6.4
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4
org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4
org.jetbrains:annotations:13.0
11 changes: 6 additions & 5 deletions workflow-runtime/dependencies/jvmRuntimeClasspath.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
com.squareup.okio:okio-jvm:3.0.0
com.squareup.okio:okio:3.0.0
org.jetbrains.kotlin:kotlin-bom:1.6.10
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.10
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.10
org.jetbrains.kotlin:kotlin-stdlib:1.6.10
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.5.1
org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21
org.jetbrains.kotlin:kotlin-stdlib:1.6.21
org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.6.4
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4
org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4
org.jetbrains:annotations:13.0
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ class RenderWorkflowInTest {
if (runtimeConfig1 is FrameTimeout) {
// Get past frame timeout to ensure snapshot saved.
testScope.advanceTimeBy(runtimeConfig1.frameTimeoutMs + 1)
testScope.runCurrent()
}
val snapshot = renderings.value.let { (rendering, snapshot) ->
val (state, updateState) = rendering
Expand Down Expand Up @@ -280,13 +281,15 @@ class RenderWorkflowInTest {
if (runtimeConfig is FrameTimeout) {
// Get past frame timeout to ensure snapshot saved.
testScope.advanceTimeBy(runtimeConfig.frameTimeoutMs + 1)
testScope.runCurrent()
}

sink.send("unchanging state")

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

scope.cancel()
Expand Down Expand Up @@ -506,6 +509,7 @@ class RenderWorkflowInTest {
trigger.complete(Unit)
if (runtimeConfig is FrameTimeout) {
testScope.advanceTimeBy(runtimeConfig.frameTimeoutMs + 1)
testScope.runCurrent()
}
assertFalse(testScope.isActive)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@file:Suppress("EXPERIMENTAL_API_USAGE", "DEPRECATION")
@file:OptIn(ExperimentalCoroutinesApi::class)

package com.squareup.workflow1.internal

Expand Down Expand Up @@ -29,12 +30,13 @@ import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.CoroutineName
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers.Unconfined
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.Job
import kotlinx.coroutines.cancel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.selects.select
import kotlinx.coroutines.suspendCancellableCoroutine
import kotlinx.coroutines.test.runTest
import kotlinx.coroutines.withTimeout
import kotlin.coroutines.CoroutineContext
import kotlin.test.AfterTest
Expand Down Expand Up @@ -173,14 +175,14 @@ internal class WorkflowNodeTest {
)
node.render(workflow, "")("event")

val result = runBlocking {
withTimeout(10) {
runTest {
val result = withTimeout(10) {
select<ActionProcessingResult?> {
node.tick(this)
} as WorkflowOutput<String>?
}
assertEquals("tick:event", result?.value)
}
assertEquals("tick:event", result?.value)
}

@Test fun `accepts events sent to stale renderings`() {
Expand Down Expand Up @@ -210,16 +212,16 @@ internal class WorkflowNodeTest {
sink("event")
sink("event2")

val result = runBlocking {
withTimeout(10) {
runTest {
val result = withTimeout(10) {
List(2) {
select<ActionProcessingResult?> {
node.tick(this)
} as WorkflowOutput<String>?
}
}
assertEquals(listOf("tick:event", "tick:event2"), result.map { it?.value })
}
assertEquals(listOf("tick:event", "tick:event2"), result.map { it?.value })
}

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

runBlocking {
runTest {
node.render(workflow.asStatefulWorkflow(), Unit)
assertTrue(started)
}
Expand Down Expand Up @@ -302,16 +304,15 @@ internal class WorkflowNodeTest {
)
node.render(workflow.asStatefulWorkflow(), Unit)

val result = runBlocking {
runTest {
// Result should be available instantly, any delay at all indicates something is broken.
withTimeout(1) {
val result = withTimeout(1) {
select<ActionProcessingResult?> {
node.tick(this)
} as WorkflowOutput<String>?
}
assertEquals("result", result?.value)
}

assertEquals("result", result?.value)
}

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

runBlocking {
runTest {
node.render(workflow.asStatefulWorkflow(), true)
assertNull(cancellationException)

Expand All @@ -357,7 +358,7 @@ internal class WorkflowNodeTest {
snapshot = null, baseContext = context
)

runBlocking {
runTest {
node.render(workflow.asStatefulWorkflow(), Unit)
assertNull(cancellationException)

Expand All @@ -383,7 +384,7 @@ internal class WorkflowNodeTest {
snapshot = null, baseContext = context
)

runBlocking {
runTest {
node.render(workflow.asStatefulWorkflow(), 0)
assertFalse(cancelled)
assertEquals(1, renderPasses)
Expand All @@ -408,7 +409,7 @@ internal class WorkflowNodeTest {
snapshot = null, baseContext = context
)

runBlocking {
runTest {
node.render(workflow.asStatefulWorkflow(), 0)
assertEquals(listOf(0), seenProps)
assertEquals(1, renderPasses)
Expand Down Expand Up @@ -1099,7 +1100,7 @@ internal class WorkflowNodeTest {

sink.send("hello")

runBlocking {
runTest {
select<ActionProcessingResult?> {
node.tick(this)
} as WorkflowOutput<String>?
Expand All @@ -1125,13 +1126,12 @@ internal class WorkflowNodeTest {

rendering.send("hello")

val output = runBlocking {
select<ActionProcessingResult?> {
runTest {
val output = select<ActionProcessingResult?> {
node.tick(this)
} as WorkflowOutput<String>?
assertEquals("output:hello", output?.value)
}

assertEquals("output:hello", output?.value)
}

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

rendering.send("hello")

val output = runBlocking {
select<ActionProcessingResult?> {
runTest {
val output = select<ActionProcessingResult?> {
node.tick(this)
} as WorkflowOutput<String>?
assertNull(output?.value)
}

assertNull(output?.value)
}

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

runBlocking {
runTest {
select<ActionProcessingResult?> {
node.tick(this)
} as WorkflowOutput<String>?
Expand All @@ -1204,13 +1203,12 @@ internal class WorkflowNodeTest {
)
node.render(workflow.asStatefulWorkflow(), Unit)

val output = runBlocking {
select<ActionProcessingResult?> {
runTest {
val output = select<ActionProcessingResult?> {
node.tick(this)
} as WorkflowOutput<String>?
assertEquals("output:child:hello", output?.value)
}

assertEquals("output:child:hello", output?.value)
}

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

val output = runBlocking {
select<ActionProcessingResult?> {
runTest {
val output = select<ActionProcessingResult?> {
node.tick(this)
} as WorkflowOutput<String>?
assertNull(output?.value)
}

assertNull(output?.value)
}

private class TestSession(override val sessionId: Long = 0) : WorkflowSession {
Expand Down
17 changes: 9 additions & 8 deletions workflow-rx2/dependencies/runtimeClasspath.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ com.squareup.okio:okio-jvm:3.0.0
com.squareup.okio:okio:3.0.0
io.reactivex.rxjava2:rxjava:2.2.21
org.jetbrains.kotlin:kotlin-bom:1.6.10
org.jetbrains.kotlin:kotlin-stdlib-common:1.6.10
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.10
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.10
org.jetbrains.kotlin:kotlin-stdlib:1.6.10
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.5.1
org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1
org.jetbrains.kotlinx:kotlinx-coroutines-reactive:1.5.1
org.jetbrains.kotlinx:kotlinx-coroutines-rx2:1.5.1
org.jetbrains.kotlin:kotlin-stdlib-common:1.6.21
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21
org.jetbrains.kotlin:kotlin-stdlib:1.6.21
org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.6.4
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4
org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4
org.jetbrains.kotlinx:kotlinx-coroutines-reactive:1.6.4
org.jetbrains.kotlinx:kotlinx-coroutines-rx2:1.6.4
org.jetbrains:annotations:13.0
org.reactivestreams:reactive-streams:1.0.3
Loading