Skip to content

Commit

Permalink
Merge branch 'main' of github.com:smithy-lang/smithy-kotlin into v1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
lauzadis committed Dec 16, 2024
2 parents 869fb84 + 7085c8a commit 652da19
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 12 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## [1.3.30] - 12/16/2024

## [1.3.29] - 12/12/2024

## [1.3.28] - 12/03/2024

## [1.3.27] - 12/02/2024

## [1.3.26] - 11/22/2024

### Fixes
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# <img alt="Smithy" src="https://github.com/smithy-lang/smithy/blob/main/docs/_static/favicon.png?raw=true" width="28"> Smithy Kotlin
# <img alt="Smithy" src="https://github.com/smithy-lang/smithy/blob/main/docs/_static/smithy-anvil.svg?raw=true" width="32"> Smithy Kotlin

[Smithy](https://smithy.io/2.0/index.html) code generators for [Kotlin](https://kotlinlang.org/).

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
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ kotlinx.atomicfu.enableNativeIrTransformation=false
org.gradle.jvmargs=-Xmx2G -XX:MaxMetaspaceSize=1G

# SDK
sdkVersion=1.3.27-SNAPSHOT
sdkVersion=1.3.31-SNAPSHOT

# codegen
codegenVersion=0.33.27-SNAPSHOT
codegenVersion=0.33.31-SNAPSHOT
1 change: 1 addition & 0 deletions runtime/runtime-core/api/runtime-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ public final class aws/smithy/kotlin/runtime/businessmetrics/SmithyBusinessMetri
public static final field WAITER Laws/smithy/kotlin/runtime/businessmetrics/SmithyBusinessMetric;
public static fun getEntries ()Lkotlin/enums/EnumEntries;
public fun getIdentifier ()Ljava/lang/String;
public fun toString ()Ljava/lang/String;
public static fun valueOf (Ljava/lang/String;)Laws/smithy/kotlin/runtime/businessmetrics/SmithyBusinessMetric;
public static fun values ()[Laws/smithy/kotlin/runtime/businessmetrics/SmithyBusinessMetric;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,7 @@ public enum class SmithyBusinessMetric(public override val identifier: String) :
SERVICE_ENDPOINT_OVERRIDE("N"),
ACCOUNT_ID_BASED_ENDPOINT("O"),
SIGV4A_SIGNING("S"),
;

override fun toString(): String = identifier
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,20 @@ public fun Any?.type(): String = when (this) {
else -> throw Exception("Undetected type for: $this")
}

// Collection `flattenIfPossible` functions
@InternalApi
@JvmName("noOpUnnestedCollection")
public inline fun <reified T> Collection<T>.flattenIfPossible(): Collection<T> = this

@InternalApi
@JvmName("flattenNestedCollection")
public inline fun <reified T> Collection<Collection<T>>.flattenIfPossible(): Collection<T> = flatten()

// List `flattenIfPossible` functions
@InternalApi
@JvmName("noOpUnnestedCollection")
public inline fun <reified T> List<T>.flattenIfPossible(): List<T> = this

@InternalApi
@JvmName("flattenNestedCollection")
public inline fun <reified T> List<List<T>>.flattenIfPossible(): List<T> = flatten()
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package aws.smithy.kotlin.runtime.businessmetrics
import aws.smithy.kotlin.runtime.collections.get
import aws.smithy.kotlin.runtime.operation.ExecutionContext
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFalse
import kotlin.test.assertTrue

Expand Down Expand Up @@ -55,4 +56,12 @@ class BusinessMetricsUtilsTest {
executionContext.removeBusinessMetric(SmithyBusinessMetric.GZIP_REQUEST_COMPRESSION)
assertFalse(executionContext.containsBusinessMetric(SmithyBusinessMetric.GZIP_REQUEST_COMPRESSION))
}

@Test
fun businessMetricToString() {
val businessMetricToString = SmithyBusinessMetric.GZIP_REQUEST_COMPRESSION.toString()
val businessMetricIdentifier = SmithyBusinessMetric.GZIP_REQUEST_COMPRESSION.identifier

assertEquals(businessMetricIdentifier, businessMetricToString)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package aws.smithy.kotlin.runtime.util

import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertTrue

class JmesPathTest {
@Test
fun flattenNestedLists() {
val nestedList = listOf(
listOf(1, 2, 3),
listOf(4, 5),
listOf(6),
)
val flattenedList = nestedList.flattenIfPossible()
assertEquals(listOf(1, 2, 3, 4, 5, 6), flattenedList)
}

@Test
fun flattenEmptyNestedLists() {
val nestedList = listOf(
listOf<Int>(),
listOf(),
listOf(),
)
val flattenedList = nestedList.flattenIfPossible()
assertTrue(flattenedList.isEmpty())
}

@Test
fun flattenNestedEmptyAndNonEmptyNestedLists() {
val nestedList = listOf(
listOf(1, 2),
listOf(),
listOf(3, 4, 5),
)
val flattenedList = nestedList.flattenIfPossible()
assertEquals(listOf(1, 2, 3, 4, 5), flattenedList)
}

@Test
fun flattenList() {
val nestedList = listOf(
listOf(1, 2, 3),
)
val flattenedList = nestedList.flattenIfPossible()
assertEquals(listOf(1, 2, 3), flattenedList)
}
}

0 comments on commit 652da19

Please sign in to comment.