diff --git a/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/core/RuntimeTypes.kt b/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/core/RuntimeTypes.kt index 172348d4e..1d4d31120 100644 --- a/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/core/RuntimeTypes.kt +++ b/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/core/RuntimeTypes.kt @@ -115,7 +115,8 @@ object RuntimeTypes { } object SmokeTests : RuntimeTypePackage(KotlinDependency.CORE, "smoketests") { - val ExitProcess = symbol("exitProcess") + val exitProcess = symbol("exitProcess") + val getEnv = symbol("getEnv") } object Collections : RuntimeTypePackage(KotlinDependency.CORE, "collections") { @@ -174,6 +175,7 @@ object RuntimeTypes { val Closeable = symbol("Closeable") val SdkManagedGroup = symbol("SdkManagedGroup") val addIfManaged = symbol("addIfManaged", isExtension = true) + val use = symbol("use") } object Text : RuntimeTypePackage(KotlinDependency.CORE, "text") { diff --git a/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/smoketests/SmokeTestsRunnerGenerator.kt b/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/smoketests/SmokeTestsRunnerGenerator.kt index fa2122ade..b83d754b4 100644 --- a/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/smoketests/SmokeTestsRunnerGenerator.kt +++ b/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/smoketests/SmokeTestsRunnerGenerator.kt @@ -39,13 +39,23 @@ class SmokeTestsRunnerGenerator( internal fun render() { writer.declareSection(SmokeTestsRunner) { write("private var exitCode = 0") - write("private val skipTags = System.getenv(#S)?.let { it.split(#S).map { it.trim() }.toSet() } ?: emptySet()", SKIP_TAGS, ",") - write("private val serviceFilter = System.getenv(#S)?.let { it.split(#S).map { it.trim() }.toSet() } ?: emptySet()", SERVICE_FILTER, ",") + write( + "private val skipTags = #T(#S)?.let { it.split(#S).map { it.trim() }.toSet() } ?: emptySet()", + RuntimeTypes.Core.SmokeTests.getEnv, + SKIP_TAGS, + ",", + ) + write( + "private val serviceFilter = #T(#S)?.let { it.split(#S).map { it.trim() }.toSet() } ?: emptySet()", + RuntimeTypes.Core.SmokeTests.getEnv, + SERVICE_FILTER, + ",", + ) declareSection(SmokeTestAdditionalEnvVars) write("") withBlock("public suspend fun main() {", "}") { renderFunctionCalls() - write("#T(exitCode)", RuntimeTypes.Core.SmokeTests.ExitProcess) + write("#T(exitCode)", RuntimeTypes.Core.SmokeTests.exitProcess) } write("") renderFunctions() @@ -120,7 +130,7 @@ class SmokeTestsRunnerGenerator( private fun renderOperation(operation: OperationShape, testCase: SmokeTestCase) { val operationSymbol = symbolProvider.toSymbol(model.getShape(operation.input.get()).get()) - writer.withBlock(".use { client ->", "}") { + writer.withBlock(".#T { client ->", "}", RuntimeTypes.Core.IO.use) { withBlock("client.#L(", ")", operation.defaultName()) { withBlock("#L {", "}", operationSymbol) { testCase.params.get().members.forEach { member -> diff --git a/runtime/runtime-core/common/src/aws/smithy/kotlin/runtime/smoketests/SmokeTestsRuntimeFunctions.kt b/runtime/runtime-core/common/src/aws/smithy/kotlin/runtime/smoketests/SmokeTestsFunctions.kt similarity index 67% rename from runtime/runtime-core/common/src/aws/smithy/kotlin/runtime/smoketests/SmokeTestsRuntimeFunctions.kt rename to runtime/runtime-core/common/src/aws/smithy/kotlin/runtime/smoketests/SmokeTestsFunctions.kt index f996632e9..d1b29a607 100644 --- a/runtime/runtime-core/common/src/aws/smithy/kotlin/runtime/smoketests/SmokeTestsRuntimeFunctions.kt +++ b/runtime/runtime-core/common/src/aws/smithy/kotlin/runtime/smoketests/SmokeTestsFunctions.kt @@ -1,3 +1,4 @@ package aws.smithy.kotlin.runtime.smoketests public expect fun exitProcess(status: Int): Nothing +public expect fun getEnv(name: String): String? diff --git a/runtime/runtime-core/jvm/src/aws/smithy/kotlin/runtime/smoketests/SmokeTestsFunctionsJVM.kt b/runtime/runtime-core/jvm/src/aws/smithy/kotlin/runtime/smoketests/SmokeTestsFunctionsJVM.kt index b11912df7..5ac7d675b 100644 --- a/runtime/runtime-core/jvm/src/aws/smithy/kotlin/runtime/smoketests/SmokeTestsFunctionsJVM.kt +++ b/runtime/runtime-core/jvm/src/aws/smithy/kotlin/runtime/smoketests/SmokeTestsFunctionsJVM.kt @@ -3,3 +3,4 @@ package aws.smithy.kotlin.runtime.smoketests import kotlin.system.exitProcess public actual fun exitProcess(status: Int): Nothing = exitProcess(status) +public actual fun getEnv(name: String): String? = System.getenv(name) diff --git a/runtime/runtime-core/native/src/aws/smithy/kotlin/runtime/smoketests/SmokeTestsFunctionsNative.kt b/runtime/runtime-core/native/src/aws/smithy/kotlin/runtime/smoketests/SmokeTestsFunctionsNative.kt index b11912df7..a2b633b79 100644 --- a/runtime/runtime-core/native/src/aws/smithy/kotlin/runtime/smoketests/SmokeTestsFunctionsNative.kt +++ b/runtime/runtime-core/native/src/aws/smithy/kotlin/runtime/smoketests/SmokeTestsFunctionsNative.kt @@ -3,3 +3,4 @@ package aws.smithy.kotlin.runtime.smoketests import kotlin.system.exitProcess public actual fun exitProcess(status: Int): Nothing = exitProcess(status) +public actual fun getEnv(name: String): String? = TODO("Not yet implemented")