Skip to content

Commit

Permalink
Run in common
Browse files Browse the repository at this point in the history
  • Loading branch information
0marperez committed Sep 24, 2024
1 parent 915e845 commit 1055f1b
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import software.amazon.smithy.model.shapes.Shape
import java.nio.file.Paths

const val DEFAULT_SOURCE_SET_ROOT = "./src/main/kotlin/"
private const val DEFAULT_TEST_SOURCE_SET_ROOT = "./src/test/kotlin/"
const val DEFAULT_TEST_SOURCE_SET_ROOT = "./src/test/kotlin/"

/**
* Manages writers for Kotlin files.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ object RuntimeTypes {
val SmithyBusinessMetric = symbol("SmithyBusinessMetric")
}

object SmokeTests : RuntimeTypePackage(KotlinDependency.CORE, "smoketests") {
val ExitProcess = symbol("exitProcess")
}

object Collections : RuntimeTypePackage(KotlinDependency.CORE, "collections") {
val Attributes = symbol("Attributes")
val attributesOf = symbol("attributesOf")
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package software.amazon.smithy.kotlin.codegen.rendering.smoketests

import software.amazon.smithy.kotlin.codegen.KotlinSettings
import software.amazon.smithy.kotlin.codegen.core.CodegenContext
import software.amazon.smithy.kotlin.codegen.core.DEFAULT_TEST_SOURCE_SET_ROOT
import software.amazon.smithy.kotlin.codegen.core.KotlinDelegator
import software.amazon.smithy.kotlin.codegen.integration.KotlinIntegration
import software.amazon.smithy.kotlin.codegen.model.hasTrait
Expand All @@ -20,7 +21,7 @@ class SmokeTestsIntegration : KotlinIntegration {
delegator.useFileWriter(
"SmokeTests.kt",
"${ctx.settings.pkg.name}.smoketests",
"./jvm-src/test/java/",
DEFAULT_TEST_SOURCE_SET_ROOT,
) { writer ->
SmokeTestsRunnerGenerator(
writer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,14 @@ class SmokeTestsRunnerGenerator(

internal fun render() {
writer.declareSection(SmokeTestsRunner) {
write("import kotlin.system.exitProcess")
write("")
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, ",")
declareSection(SmokeTestAdditionalEnvVars)
write("")
withBlock("public suspend fun main() {", "}") {
renderFunctionCalls()
write("exitProcess(exitCode)")
write("#T(exitCode)", RuntimeTypes.Core.SmokeTests.ExitProcess)
}
write("")
renderFunctions()
Expand Down
4 changes: 4 additions & 0 deletions runtime/runtime-core/api/runtime-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -2044,6 +2044,10 @@ public final class aws/smithy/kotlin/runtime/retries/policy/SuccessAcceptor : aw
public final fun getSuccess ()Z
}

public final class aws/smithy/kotlin/runtime/smoketests/SmokeTestsFunctionsJVMKt {
public static final fun exitProcess (I)Ljava/lang/Void;
}

public final class aws/smithy/kotlin/runtime/text/Scanner {
public fun <init> (Ljava/lang/String;)V
public final fun getText ()Ljava/lang/String;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package aws.smithy.kotlin.runtime.smoketests

public expect fun exitProcess(status: Int): Nothing
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package aws.smithy.kotlin.runtime.smoketests

import kotlin.system.exitProcess

public actual fun exitProcess(status: Int): Nothing = exitProcess(status)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package aws.smithy.kotlin.runtime.smoketests

import kotlin.system.exitProcess

public actual fun exitProcess(status: Int): Nothing = exitProcess(status)

0 comments on commit 1055f1b

Please sign in to comment.