From 9083332462ddc74a795dba4e98e2d0445af4875e Mon Sep 17 00:00:00 2001 From: Matas Lauzadis Date: Tue, 17 Oct 2023 15:21:25 -0400 Subject: [PATCH] Share `runBlockingTest` implementation in jvmAndNative --- .../http/test/util/AbstractEngineTestJVM.kt | 21 -------------- .../util/AbstractEngineTestJvmAndNative.kt | 28 +++++++++++++++++++ .../test/util/AbstractEngineTestNative.kt | 19 +------------ 3 files changed, 29 insertions(+), 39 deletions(-) create mode 100644 runtime/protocol/http-client-engines/test-suite/jvmAndNative/src/aws/smithy/kotlin/runtime/http/test/util/AbstractEngineTestJvmAndNative.kt diff --git a/runtime/protocol/http-client-engines/test-suite/jvm/src/aws/smithy/kotlin/runtime/http/test/util/AbstractEngineTestJVM.kt b/runtime/protocol/http-client-engines/test-suite/jvm/src/aws/smithy/kotlin/runtime/http/test/util/AbstractEngineTestJVM.kt index 372e30ed5..e6270c14e 100644 --- a/runtime/protocol/http-client-engines/test-suite/jvm/src/aws/smithy/kotlin/runtime/http/test/util/AbstractEngineTestJVM.kt +++ b/runtime/protocol/http-client-engines/test-suite/jvm/src/aws/smithy/kotlin/runtime/http/test/util/AbstractEngineTestJVM.kt @@ -7,30 +7,9 @@ package aws.smithy.kotlin.runtime.http.test.util import aws.smithy.kotlin.runtime.http.engine.DefaultHttpEngine import aws.smithy.kotlin.runtime.http.engine.crt.CrtHttpEngine -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.runBlocking -import kotlinx.coroutines.withTimeout -import kotlin.coroutines.CoroutineContext -import kotlin.time.Duration internal actual fun engineFactories(): List = listOf( TestEngineFactory("DefaultHttpEngine", ::DefaultHttpEngine), TestEngineFactory("CrtHttpEngine") { CrtHttpEngine(it) }, ) - -internal actual fun runBlockingTest( - context: CoroutineContext, - timeout: Duration?, - block: suspend CoroutineScope.() -> Unit, -) { - runBlocking(context) { - if (timeout != null) { - withTimeout(timeout) { - block() - } - } else { - block() - } - } -} diff --git a/runtime/protocol/http-client-engines/test-suite/jvmAndNative/src/aws/smithy/kotlin/runtime/http/test/util/AbstractEngineTestJvmAndNative.kt b/runtime/protocol/http-client-engines/test-suite/jvmAndNative/src/aws/smithy/kotlin/runtime/http/test/util/AbstractEngineTestJvmAndNative.kt new file mode 100644 index 000000000..97dfde4fd --- /dev/null +++ b/runtime/protocol/http-client-engines/test-suite/jvmAndNative/src/aws/smithy/kotlin/runtime/http/test/util/AbstractEngineTestJvmAndNative.kt @@ -0,0 +1,28 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +package aws.smithy.kotlin.runtime.http.test.util + +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.runBlocking +import kotlinx.coroutines.withTimeout +import kotlin.coroutines.CoroutineContext +import kotlin.time.Duration + +internal actual fun runBlockingTest( + context: CoroutineContext, + timeout: Duration?, + block: suspend CoroutineScope.() -> Unit, +) { + runBlocking(context) { + if (timeout != null) { + withTimeout(timeout) { + block() + } + } else { + block() + } + } +} diff --git a/runtime/protocol/http-client-engines/test-suite/native/src/aws/smithy/kotlin/runtime/http/test/util/AbstractEngineTestNative.kt b/runtime/protocol/http-client-engines/test-suite/native/src/aws/smithy/kotlin/runtime/http/test/util/AbstractEngineTestNative.kt index 58bb86e5b..41079f25b 100644 --- a/runtime/protocol/http-client-engines/test-suite/native/src/aws/smithy/kotlin/runtime/http/test/util/AbstractEngineTestNative.kt +++ b/runtime/protocol/http-client-engines/test-suite/native/src/aws/smithy/kotlin/runtime/http/test/util/AbstractEngineTestNative.kt @@ -13,21 +13,4 @@ import kotlin.time.Duration // FIXME add engines to test internal actual fun engineFactories(): List = - listOf() - -// FIXME duplicated from jvm source -internal actual fun runBlockingTest( - context: CoroutineContext, - timeout: Duration?, - block: suspend CoroutineScope.() -> Unit, -) { - runBlocking(context) { - if (timeout != null) { - withTimeout(timeout) { - block() - } - } else { - block() - } - } -} + listOf() \ No newline at end of file