You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
That is the symbol provider that the client uses, which is very different from the server one (for example, the client generates Optional types for @required members, and the server doesn't).
It should instead be using serverTestSymbolProvider:
However, we can't make it use that symbol provider, because the server symbol provider is in ServerTestHelpers.kt, part of the codegen-server subproject's test sources. But EventStreamUnmarshallerGeneratorTest.kt is in the codegen subproject. codegen cannot depend on codegen-server, it's the other way around.
One way to fix this would be to have codegen-server's test sources depend on codegen's test sources. We would rewrite the test case provider in the server subproject to use the serverTestSymbolProvider, and then the test would just delegate to EventStreamUnmarshallerGeneratorTest.kt passing it the modified test case. I've tried looking into this and it's not straightforward.
The examples above are in Groovy; I don't know how to do it in the Kotlin DSL. Gradle's official documentation seems to recommend the testFixtures approach for sharing test code across projects, but in our case we would not only want to share the test cases but also the test code from EventStreamUnmarshallerGeneratorTest.kt. I don't know if that's abusing the testFixtures pattern.
To me it seems like this is yet another indication that we should restructure smithy-rs to have three subprojects: a core library, the client plugin, and the server plugin. Both the client and server plugins would depend on the core library's implementation and test code.
The text was updated successfully, but these errors were encountered:
To me it seems like this is yet another indication that we should restructure smithy-rs to have three subprojects: a core library, the client plugin, and the server plugin. Both the client and server plugins would depend on the core library's implementation and test code.
* Move the allow lints customization into `codegen-core`
* Move the crate version customization into `codegen-core`
* Move "pub use" extra into `codegen-core`
* Move `EventStreamSymbolProvider` into `codegen-core`
* Move the streaming shape providers into `codegen-core`
* Refactor event stream marshall/unmarshall tests
* Break `codegen-server` dependency on `codegen-client`
* Split up `EventStreamTestTools`
* Move codegen context creation in event stream tests
* Restructure tests so that #1442 is easier to resolve in the future
* Add client/server prefixes to test classes
* Improve TODO comments in server event stream tests
* Use correct builders for `ServerEventStreamMarshallerGeneratorTest`
* Remove test cases for protocols that don't support event streams
The tests in
EventStreamUnmarshallerGeneratorTest.kt
are being run for the server because inEventStreamTestTools.kt
we have:https://github.com/awslabs/smithy-rs/blob/242e6bcd677b5600f27106f8bc45f411c3c429da/codegen/src/test/kotlin/software/amazon/smithy/rust/codegen/smithy/protocols/EventStreamTestTools.kt#L306-L306
That is, each test case is duplicated: one with
CodegenTarget.CLIENT
, one withCodegenTarget.SERVER
.The problem is this is incorrect, because both test types are using the
testSymbolProvider
fromTestHelpers.kt
https://github.com/awslabs/smithy-rs/blob/242e6bcd677b5600f27106f8bc45f411c3c429da/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/testutil/TestHelpers.kt#L66-L71
That is the symbol provider that the client uses, which is very different from the server one (for example, the client generates
Option
al types for@required
members, and the server doesn't).It should instead be using
serverTestSymbolProvider
:https://github.com/awslabs/smithy-rs/blob/242e6bcd677b5600f27106f8bc45f411c3c429da/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/testutil/ServerTestHelpers.kt#L30-L35
However, we can't make it use that symbol provider, because the server symbol provider is in
ServerTestHelpers.kt
, part of thecodegen-server
subproject's test sources. ButEventStreamUnmarshallerGeneratorTest.kt
is in thecodegen
subproject.codegen
cannot depend oncodegen-server
, it's the other way around.One way to fix this would be to have
codegen-server
's test sources depend oncodegen
's test sources. We would rewrite the test case provider in the server subproject to use theserverTestSymbolProvider
, and then the test would just delegate toEventStreamUnmarshallerGeneratorTest.kt
passing it the modified test case. I've tried looking into this and it's not straightforward.The examples above are in Groovy; I don't know how to do it in the Kotlin DSL. Gradle's official documentation seems to recommend the
testFixtures
approach for sharing test code across projects, but in our case we would not only want to share the test cases but also the test code fromEventStreamUnmarshallerGeneratorTest.kt
. I don't know if that's abusing thetestFixtures
pattern.To me it seems like this is yet another indication that we should restructure smithy-rs to have three subprojects: a core library, the client plugin, and the server plugin. Both the client and server plugins would depend on the core library's implementation and test code.
The text was updated successfully, but these errors were encountered: