9
9
from aws_lambda_builders .workflows .rust_cargo .feature_flag import EXPERIMENTAL_FLAG_CARGO_LAMBDA
10
10
11
11
12
- def rm_target_lambda (base ):
13
- shutil .rmtree (os .path .join (base , "target" , "lambda" ), ignore_errors = True )
12
+ def rm_target (base ):
13
+ shutil .rmtree (os .path .join (base , "target" ), ignore_errors = True )
14
14
15
15
16
16
class TestRustCargo (TestCase ):
@@ -52,7 +52,7 @@ def test_failed_build_project(self):
52
52
53
53
def test_builds_hello_project (self ):
54
54
source_dir = os .path .join (self .TEST_DATA_FOLDER , "hello" )
55
- rm_target_lambda (source_dir )
55
+ rm_target (source_dir )
56
56
57
57
self .builder .build (
58
58
source_dir ,
@@ -70,7 +70,7 @@ def test_builds_hello_project(self):
70
70
71
71
def test_builds_hello_project_with_artifact_name (self ):
72
72
source_dir = os .path .join (self .TEST_DATA_FOLDER , "hello" )
73
- rm_target_lambda (source_dir )
73
+ rm_target (source_dir )
74
74
75
75
self .builder .build (
76
76
source_dir ,
@@ -89,7 +89,7 @@ def test_builds_hello_project_with_artifact_name(self):
89
89
90
90
def test_builds_hello_project_for_arm64 (self ):
91
91
source_dir = os .path .join (self .TEST_DATA_FOLDER , "hello" )
92
- rm_target_lambda (source_dir )
92
+ rm_target (source_dir )
93
93
94
94
self .builder .build (
95
95
source_dir ,
@@ -109,10 +109,10 @@ def test_builds_hello_project_for_arm64(self):
109
109
110
110
def test_builds_workspaces_project_with_bin_name (self ):
111
111
source_dir = os .path .join (self .TEST_DATA_FOLDER , "workspaces" )
112
- rm_target_lambda (source_dir )
112
+ rm_target (source_dir )
113
113
114
114
self .builder .build (
115
- source_dir ,
115
+ f" { source_dir } " ,
116
116
self .artifacts_dir ,
117
117
self .scratch_dir ,
118
118
os .path .join (source_dir , "Cargo.toml" ),
@@ -125,10 +125,30 @@ def test_builds_workspaces_project_with_bin_name(self):
125
125
output_files = set (os .listdir (self .artifacts_dir ))
126
126
127
127
self .assertEqual (expected_files , output_files )
128
+ self .assertIn ("foo" , os .listdir (os .path .join (source_dir , "target" , "lambda" )))
129
+
130
+ def test_builds_workspace_member (self ):
131
+ source_dir = os .path .join (self .TEST_DATA_FOLDER , "workspaces" )
132
+ rm_target (source_dir )
133
+
134
+ self .builder .build (
135
+ f"{ source_dir } /bar" ,
136
+ self .artifacts_dir ,
137
+ self .scratch_dir ,
138
+ os .path .join (source_dir , "Cargo.toml" ),
139
+ runtime = self .runtime ,
140
+ experimental_flags = [EXPERIMENTAL_FLAG_CARGO_LAMBDA ],
141
+ )
142
+
143
+ expected_files = {"bootstrap" }
144
+ output_files = set (os .listdir (self .artifacts_dir ))
145
+
146
+ self .assertEqual (expected_files , output_files )
147
+ self .assertIn ("bar" , os .path .join (source_dir , "bar" , "target" , "lambda" ))
128
148
129
149
def test_builds_workspaces_project_with_package_option (self ):
130
150
source_dir = os .path .join (self .TEST_DATA_FOLDER , "workspaces" )
131
- rm_target_lambda (source_dir )
151
+ rm_target (source_dir )
132
152
133
153
self .builder .build (
134
154
source_dir ,
@@ -147,7 +167,7 @@ def test_builds_workspaces_project_with_package_option(self):
147
167
148
168
def test_builds_multi_function_project_with_function_a (self ):
149
169
source_dir = os .path .join (self .TEST_DATA_FOLDER , "multi-binary" )
150
- rm_target_lambda (source_dir )
170
+ rm_target (source_dir )
151
171
152
172
self .builder .build (
153
173
source_dir ,
@@ -166,7 +186,7 @@ def test_builds_multi_function_project_with_function_a(self):
166
186
167
187
def test_builds_multi_function_project_with_function_b (self ):
168
188
source_dir = os .path .join (self .TEST_DATA_FOLDER , "multi-binary" )
169
- rm_target_lambda (source_dir )
189
+ rm_target (source_dir )
170
190
171
191
self .builder .build (
172
192
source_dir ,
0 commit comments