-
Notifications
You must be signed in to change notification settings - Fork 211
Break codegen-server
's dependency on codegen-client
#2105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
53e25af
Move the allow lints customization into `codegen-core`
jdisanti ed84f25
Move the crate version customization into `codegen-core`
jdisanti bc804ce
Move "pub use" extra into `codegen-core`
jdisanti 46494d4
Move `EventStreamSymbolProvider` into `codegen-core`
jdisanti 40f876a
Move the streaming shape providers into `codegen-core`
jdisanti 608f1c4
Refactor event stream marshall/unmarshall tests
jdisanti 69cdfc8
Break `codegen-server` dependency on `codegen-client`
jdisanti b8b6ed5
Split up `EventStreamTestTools`
jdisanti d93346e
Move codegen context creation in event stream tests
jdisanti 52899f9
Restructure tests so that #1442 is easier to resolve in the future
jdisanti 5f7bc7e
Fix comments in `SmithyTypesPubUseExtra`
jdisanti 2dd9881
Use pair instead of list
jdisanti 2659182
Merge remote-tracking branch 'origin/main' into jdisanti-break-client…
jdisanti be77fa0
Simplify base event stream test requirements
jdisanti c608a77
Explode on unrecognized shape types in event stream test tools
jdisanti 5c73370
Add client/server prefixes to test classes
jdisanti a47597f
Improve TODO comments in server event stream tests
jdisanti 0b77d8f
Use correct builders for `ServerEventStreamMarshallerGeneratorTest`
jdisanti c898100
Merge remote-tracking branch 'origin/main' into jdisanti-break-client…
jdisanti 38598f2
Fix shape check in event stream test tools
jdisanti 80ed7a9
Remove test cases for protocols that don't support event streams
jdisanti File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...thy/rust/codegen/client/smithy/protocols/eventstream/ClientEventStreamBaseRequirements.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package software.amazon.smithy.rust.codegen.client.smithy.protocols.eventstream | ||
|
||
import org.junit.jupiter.api.extension.ExtensionContext | ||
import org.junit.jupiter.params.provider.Arguments | ||
import org.junit.jupiter.params.provider.ArgumentsProvider | ||
import software.amazon.smithy.model.Model | ||
import software.amazon.smithy.model.shapes.ServiceShape | ||
import software.amazon.smithy.model.shapes.ShapeId | ||
import software.amazon.smithy.model.shapes.StructureShape | ||
import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext | ||
import software.amazon.smithy.rust.codegen.client.smithy.customize.CombinedClientCodegenDecorator | ||
import software.amazon.smithy.rust.codegen.client.testutil.clientTestRustSettings | ||
import software.amazon.smithy.rust.codegen.client.testutil.testSymbolProvider | ||
import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter | ||
import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget | ||
import software.amazon.smithy.rust.codegen.core.smithy.generators.BuilderGenerator | ||
import software.amazon.smithy.rust.codegen.core.smithy.generators.implBlock | ||
import software.amazon.smithy.rust.codegen.core.testutil.EventStreamTestModels | ||
import software.amazon.smithy.rust.codegen.core.testutil.EventStreamTestRequirements | ||
import java.util.stream.Stream | ||
|
||
class TestCasesProvider : ArgumentsProvider { | ||
override fun provideArguments(context: ExtensionContext?): Stream<out Arguments> = | ||
EventStreamTestModels.TEST_CASES.map { Arguments.of(it) }.stream() | ||
} | ||
|
||
abstract class ClientEventStreamBaseRequirements : EventStreamTestRequirements<ClientCodegenContext> { | ||
override fun createCodegenContext( | ||
model: Model, | ||
serviceShape: ServiceShape, | ||
protocolShapeId: ShapeId, | ||
codegenTarget: CodegenTarget, | ||
): ClientCodegenContext = ClientCodegenContext( | ||
model, | ||
testSymbolProvider(model), | ||
serviceShape, | ||
protocolShapeId, | ||
clientTestRustSettings(), | ||
CombinedClientCodegenDecorator(emptyList()), | ||
) | ||
|
||
override fun renderBuilderForShape( | ||
writer: RustWriter, | ||
codegenContext: ClientCodegenContext, | ||
shape: StructureShape, | ||
) { | ||
BuilderGenerator(codegenContext.model, codegenContext.symbolProvider, shape).apply { | ||
render(writer) | ||
writer.implBlock(shape, codegenContext.symbolProvider) { | ||
renderConvenienceMethod(writer) | ||
} | ||
} | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
...t/codegen/client/smithy/protocols/eventstream/ClientEventStreamMarshallerGeneratorTest.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package software.amazon.smithy.rust.codegen.client.smithy.protocols.eventstream | ||
|
||
import org.junit.jupiter.params.ParameterizedTest | ||
import org.junit.jupiter.params.provider.ArgumentsSource | ||
import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext | ||
import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget | ||
import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType | ||
import software.amazon.smithy.rust.codegen.core.smithy.protocols.Protocol | ||
import software.amazon.smithy.rust.codegen.core.smithy.protocols.serialize.EventStreamMarshallerGenerator | ||
import software.amazon.smithy.rust.codegen.core.testutil.EventStreamTestModels | ||
import software.amazon.smithy.rust.codegen.core.testutil.EventStreamTestTools | ||
import software.amazon.smithy.rust.codegen.core.testutil.EventStreamTestVariety | ||
import software.amazon.smithy.rust.codegen.core.testutil.TestEventStreamProject | ||
import software.amazon.smithy.rust.codegen.core.testutil.TestRuntimeConfig | ||
|
||
class ClientEventStreamMarshallerGeneratorTest { | ||
@ParameterizedTest | ||
@ArgumentsSource(TestCasesProvider::class) | ||
fun test(testCase: EventStreamTestModels.TestCase) { | ||
EventStreamTestTools.runTestCase( | ||
testCase, | ||
object : ClientEventStreamBaseRequirements() { | ||
override fun renderGenerator( | ||
codegenContext: ClientCodegenContext, | ||
project: TestEventStreamProject, | ||
protocol: Protocol, | ||
): RuntimeType = EventStreamMarshallerGenerator( | ||
project.model, | ||
CodegenTarget.CLIENT, | ||
TestRuntimeConfig, | ||
project.symbolProvider, | ||
project.streamShape, | ||
protocol.structuredDataSerializer(project.operationShape), | ||
testCase.requestContentType, | ||
).render() | ||
}, | ||
CodegenTarget.CLIENT, | ||
EventStreamTestVariety.Marshall, | ||
) | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
...codegen/client/smithy/protocols/eventstream/ClientEventStreamUnmarshallerGeneratorTest.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package software.amazon.smithy.rust.codegen.client.smithy.protocols.eventstream | ||
|
||
import org.junit.jupiter.params.ParameterizedTest | ||
import org.junit.jupiter.params.provider.ArgumentsSource | ||
import software.amazon.smithy.codegen.core.Symbol | ||
import software.amazon.smithy.model.shapes.StructureShape | ||
import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext | ||
import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget | ||
import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType | ||
import software.amazon.smithy.rust.codegen.core.smithy.generators.builderSymbol | ||
import software.amazon.smithy.rust.codegen.core.smithy.protocols.Protocol | ||
import software.amazon.smithy.rust.codegen.core.smithy.protocols.parse.EventStreamUnmarshallerGenerator | ||
import software.amazon.smithy.rust.codegen.core.testutil.EventStreamTestModels | ||
import software.amazon.smithy.rust.codegen.core.testutil.EventStreamTestTools | ||
import software.amazon.smithy.rust.codegen.core.testutil.EventStreamTestVariety | ||
import software.amazon.smithy.rust.codegen.core.testutil.TestEventStreamProject | ||
|
||
class ClientEventStreamUnmarshallerGeneratorTest { | ||
@ParameterizedTest | ||
@ArgumentsSource(TestCasesProvider::class) | ||
fun test(testCase: EventStreamTestModels.TestCase) { | ||
EventStreamTestTools.runTestCase( | ||
testCase, | ||
object : ClientEventStreamBaseRequirements() { | ||
override fun renderGenerator( | ||
codegenContext: ClientCodegenContext, | ||
project: TestEventStreamProject, | ||
protocol: Protocol, | ||
): RuntimeType { | ||
fun builderSymbol(shape: StructureShape): Symbol = shape.builderSymbol(codegenContext.symbolProvider) | ||
return EventStreamUnmarshallerGenerator( | ||
protocol, | ||
codegenContext, | ||
project.operationShape, | ||
project.streamShape, | ||
::builderSymbol, | ||
).render() | ||
} | ||
}, | ||
CodegenTarget.CLIENT, | ||
EventStreamTestVariety.Unmarshall, | ||
) | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.