Skip to content

Commit

Permalink
misc: enable smoke tests (#1194)
Browse files Browse the repository at this point in the history
  • Loading branch information
0marperez authored Dec 12, 2024
1 parent 394eb3b commit 8cbff71
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ 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
import software.amazon.smithy.kotlin.codegen.utils.topDownOperations
import software.amazon.smithy.model.Model
import software.amazon.smithy.smoketests.traits.SmokeTestsTrait

Expand All @@ -13,9 +15,7 @@ import software.amazon.smithy.smoketests.traits.SmokeTestsTrait
*/
class SmokeTestsIntegration : KotlinIntegration {
override fun enabledForService(model: Model, settings: KotlinSettings): Boolean =
false
// FIXME: Enable smoke tests again
// model.topDownOperations(settings.service).any { it.hasTrait<SmokeTestsTrait>() }
model.topDownOperations(settings.service).any { it.hasTrait<SmokeTestsTrait>() }

override fun writeAdditionalFiles(ctx: CodegenContext, delegator: KotlinDelegator) =
delegator.useFileWriter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ object SmokeTestSectionIds {
object HttpEngineOverride : SectionId
object ServiceFilter : SectionId
object SkipTags : SectionId
object SmokeTestsFile : SectionId
object ClientConfig : SectionId {
val Name: SectionKey<String> = SectionKey("aws.smithy.kotlin#SmokeTestClientConfigName")
val Value: SectionKey<String> = SectionKey("aws.smithy.kotlin#SmokeTestClientConfigValue")
Expand Down Expand Up @@ -59,16 +60,18 @@ class SmokeTestsRunnerGenerator(
ctx: CodegenContext,
) {
internal fun render() {
writer.write("private var exitCode = 0")
renderEnvironmentVariables()
writer.declareSection(SmokeTestSectionIds.AdditionalEnvironmentVariables)
writer.write("")
writer.withBlock("public suspend fun main() {", "}") {
renderFunctionCalls()
write("#T(exitCode)", RuntimeTypes.Core.SmokeTests.exitProcess)
writer.declareSection(SmokeTestSectionIds.SmokeTestsFile) {
writer.write("private var exitCode = 0")
renderEnvironmentVariables()
writer.declareSection(SmokeTestSectionIds.AdditionalEnvironmentVariables)
writer.write("")
writer.withBlock("public suspend fun main() {", "}") {
renderFunctionCalls()
write("#T(exitCode)", RuntimeTypes.Core.SmokeTests.exitProcess)
}
writer.write("")
renderFunctions()
}
writer.write("")
renderFunctions()
}

private fun renderEnvironmentVariables() {
Expand Down

0 comments on commit 8cbff71

Please sign in to comment.