Skip to content

Commit

Permalink
Move some functions to common KMP code
Browse files Browse the repository at this point in the history
  • Loading branch information
0marperez committed Sep 24, 2024
1 parent 1055f1b commit bd0072c
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down Expand Up @@ -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") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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 ->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
package aws.smithy.kotlin.runtime.smoketests

public expect fun exitProcess(status: Int): Nothing
public expect fun getEnv(name: String): String?
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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")

0 comments on commit bd0072c

Please sign in to comment.