@@ -15,6 +15,7 @@ plugins {
15
15
val smithyVersion: String by project
16
16
val defaultRustDocFlags: String by project
17
17
val properties = PropertyRetriever (rootProject, project)
18
+ fun getSmithyRuntimeMode (): String = properties.get(" smithy.runtime.mode" ) ? : " middleware"
18
19
19
20
val pluginName = " rust-client-codegen"
20
21
val workingDirUnderBuildDir = " smithyprojections/codegen-client-test/"
@@ -33,71 +34,82 @@ dependencies {
33
34
implementation(" software.amazon.smithy:smithy-aws-traits:$smithyVersion " )
34
35
}
35
36
36
- val allCodegenTests = " ../codegen-core/common-test-models" .let { commonModels ->
37
- listOf (
38
- CodegenTest (" com.amazonaws.simple#SimpleService" , " simple" , imports = listOf (" $commonModels /simple.smithy" )),
39
- CodegenTest (" com.amazonaws.dynamodb#DynamoDB_20120810" , " dynamo" ),
40
- CodegenTest (" com.amazonaws.ebs#Ebs" , " ebs" , imports = listOf (" $commonModels /ebs.json" )),
41
- CodegenTest (" aws.protocoltests.json10#JsonRpc10" , " json_rpc10" ),
42
- CodegenTest (" aws.protocoltests.json#JsonProtocol" , " json_rpc11" ),
43
- CodegenTest (" aws.protocoltests.restjson#RestJson" , " rest_json" ),
44
- CodegenTest (" aws.protocoltests.restjson#RestJsonExtras" , " rest_json_extras" , imports = listOf (" $commonModels /rest-json-extras.smithy" )),
45
- CodegenTest (" aws.protocoltests.misc#MiscService" , " misc" , imports = listOf (" $commonModels /misc.smithy" )),
46
- CodegenTest (
47
- " aws.protocoltests.restxml#RestXml" , " rest_xml" ,
48
- extraConfig = """ , "codegen": { "addMessageToErrors": false } """ ,
49
- ),
50
-
51
- CodegenTest (
52
- " aws.protocoltests.query#AwsQuery" , " aws_query" ,
53
- extraConfig = """ , "codegen": { "addMessageToErrors": false } """ ,
54
- ),
55
- CodegenTest (
56
- " aws.protocoltests.ec2#AwsEc2" , " ec2_query" ,
57
- extraConfig = """ , "codegen": { "addMessageToErrors": false } """ ,
58
- ),
59
- CodegenTest (
60
- " aws.protocoltests.restxml.xmlns#RestXmlWithNamespace" ,
61
- " rest_xml_namespace" ,
62
- extraConfig = """ , "codegen": { "addMessageToErrors": false } """ ,
63
- ),
64
- CodegenTest (
65
- " aws.protocoltests.restxml#RestXmlExtras" ,
66
- " rest_xml_extras" ,
67
- extraConfig = """ , "codegen": { "addMessageToErrors": false } """ ,
68
- ),
69
- CodegenTest (
70
- " aws.protocoltests.restxmlunwrapped#RestXmlExtrasUnwrappedErrors" ,
71
- " rest_xml_extras_unwrapped" ,
72
- extraConfig = """ , "codegen": { "addMessageToErrors": false } """ ,
73
- ),
74
- CodegenTest (
75
- " crate#Config" ,
76
- " naming_test_ops" ,
77
- """
78
- , "codegen": { "renameErrors": false }
79
- """ .trimIndent(),
80
- imports = listOf (" $commonModels /naming-obstacle-course-ops.smithy" ),
81
- ),
82
- CodegenTest (
83
- " casing#ACRONYMInside_Service" ,
84
- " naming_test_casing" ,
85
- imports = listOf (" $commonModels /naming-obstacle-course-casing.smithy" ),
86
- ),
87
- CodegenTest (
88
- " naming_obs_structs#NamingObstacleCourseStructs" ,
89
- " naming_test_structs" ,
90
- """
91
- , "codegen": { "renameErrors": false }
92
- """ .trimIndent(),
93
- imports = listOf (" $commonModels /naming-obstacle-course-structs.smithy" ),
94
- ),
95
- CodegenTest (" aws.protocoltests.json#TestService" , " endpoint-rules" ),
96
- CodegenTest (" com.aws.example#PokemonService" , " pokemon-service-client" , imports = listOf (" $commonModels /pokemon.smithy" , " $commonModels /pokemon-common.smithy" )),
97
- CodegenTest (" com.aws.example#PokemonService" , " pokemon-service-awsjson-client" , imports = listOf (" $commonModels /pokemon-awsjson.smithy" , " $commonModels /pokemon-common.smithy" )),
37
+ data class ClientTest (
38
+ val serviceShapeName : String ,
39
+ val moduleName : String ,
40
+ val dependsOn : List <String > = emptyList(),
41
+ val addMessageToErrors : Boolean = true ,
42
+ val renameErrors : Boolean = true ,
43
+ ) {
44
+ fun toCodegenTest (): CodegenTest = CodegenTest (
45
+ serviceShapeName,
46
+ moduleName,
47
+ extraCodegenConfig = extraCodegenConfig(),
48
+ imports = imports(),
98
49
)
50
+
51
+ private fun extraCodegenConfig (): String = StringBuilder ().apply {
52
+ append(" \" addMessageToErrors\" : $addMessageToErrors ,\n " )
53
+ append(" \" renameErrors\" : $renameErrors \n ," )
54
+ append(" \" enableNewSmithyRuntime\" : \" ${getSmithyRuntimeMode()} \" " )
55
+ }.toString()
56
+
57
+ private fun imports (): List <String > = dependsOn.map { " ../codegen-core/common-test-models/$it " }
99
58
}
100
59
60
+ val allCodegenTests = listOf (
61
+ ClientTest (" com.amazonaws.simple#SimpleService" , " simple" , dependsOn = listOf (" simple.smithy" )),
62
+ ClientTest (" com.amazonaws.dynamodb#DynamoDB_20120810" , " dynamo" ),
63
+ ClientTest (" com.amazonaws.ebs#Ebs" , " ebs" , dependsOn = listOf (" ebs.json" )),
64
+ ClientTest (" aws.protocoltests.json10#JsonRpc10" , " json_rpc10" ),
65
+ ClientTest (" aws.protocoltests.json#JsonProtocol" , " json_rpc11" ),
66
+ ClientTest (" aws.protocoltests.restjson#RestJson" , " rest_json" ),
67
+ ClientTest (
68
+ " aws.protocoltests.restjson#RestJsonExtras" ,
69
+ " rest_json_extras" ,
70
+ dependsOn = listOf (" rest-json-extras.smithy" ),
71
+ ),
72
+ ClientTest (" aws.protocoltests.misc#MiscService" , " misc" , dependsOn = listOf (" misc.smithy" )),
73
+ ClientTest (" aws.protocoltests.restxml#RestXml" , " rest_xml" , addMessageToErrors = false ),
74
+ ClientTest (" aws.protocoltests.query#AwsQuery" , " aws_query" , addMessageToErrors = false ),
75
+ ClientTest (" aws.protocoltests.ec2#AwsEc2" , " ec2_query" , addMessageToErrors = false ),
76
+ ClientTest (" aws.protocoltests.restxml.xmlns#RestXmlWithNamespace" , " rest_xml_namespace" , addMessageToErrors = false ),
77
+ ClientTest (" aws.protocoltests.restxml#RestXmlExtras" , " rest_xml_extras" , addMessageToErrors = false ),
78
+ ClientTest (
79
+ " aws.protocoltests.restxmlunwrapped#RestXmlExtrasUnwrappedErrors" ,
80
+ " rest_xml_extras_unwrapped" ,
81
+ addMessageToErrors = false ,
82
+ ),
83
+ ClientTest (
84
+ " crate#Config" ,
85
+ " naming_test_ops" ,
86
+ dependsOn = listOf (" naming-obstacle-course-ops.smithy" ),
87
+ renameErrors = false ,
88
+ ),
89
+ ClientTest (
90
+ " casing#ACRONYMInside_Service" ,
91
+ " naming_test_casing" ,
92
+ dependsOn = listOf (" naming-obstacle-course-casing.smithy" ),
93
+ ),
94
+ ClientTest (
95
+ " naming_obs_structs#NamingObstacleCourseStructs" ,
96
+ " naming_test_structs" ,
97
+ dependsOn = listOf (" naming-obstacle-course-structs.smithy" ),
98
+ renameErrors = false ,
99
+ ),
100
+ ClientTest (" aws.protocoltests.json#TestService" , " endpoint-rules" ),
101
+ ClientTest (
102
+ " com.aws.example#PokemonService" ,
103
+ " pokemon-service-client" ,
104
+ dependsOn = listOf (" pokemon.smithy" , " pokemon-common.smithy" ),
105
+ ),
106
+ ClientTest (
107
+ " com.aws.example#PokemonService" ,
108
+ " pokemon-service-awsjson-client" ,
109
+ dependsOn = listOf (" pokemon-awsjson.smithy" , " pokemon-common.smithy" ),
110
+ ),
111
+ ).map(ClientTest ::toCodegenTest)
112
+
101
113
project.registerGenerateSmithyBuildTask(rootProject, pluginName, allCodegenTests)
102
114
project.registerGenerateCargoWorkspaceTask(rootProject, pluginName, allCodegenTests, workingDirUnderBuildDir)
103
115
project.registerGenerateCargoConfigTomlTask(buildDir.resolve(workingDirUnderBuildDir))
0 commit comments