@@ -171,6 +171,46 @@ def test_merge(self):
171171 )
172172 self .assertEqual (build_targets , ["//..." , "-//experimental/..." , "//experimental/good/..." ])
173173
174+ class MatrixExpansion (unittest .TestCase ):
175+ _CONFIGS = yaml .safe_load (
176+ """
177+ matrix:
178+ bazel: ["1.2.3", "2.3.4"]
179+ platform: ["pf1", "pf2"]
180+ tasks:
181+ basic:
182+ name: "Basic"
183+ unformatted:
184+ name: "Unformatted"
185+ bazel: ${{ bazel }}
186+ without_name:
187+ bazel: ${{ bazel }}
188+ formatted:
189+ name: "Formatted w/ Bazel v{bazel} on {platform}"
190+ bazel: ${{ bazel }}
191+ platform: ${{ platform }}
192+ """
193+ )
194+
195+ def test_basic_functionality (self ):
196+ config = self ._CONFIGS
197+
198+ bazelci .expand_task_config (config )
199+ expanded_tasks = config ["tasks" ]
200+ self .assertEqual (len (expanded_tasks ), 9 )
201+ expanded_task_names = [task .get ("name" , None ) for id , task in expanded_tasks .items ()]
202+ self .assertEqual (expanded_task_names , [
203+ "Basic" , # no matrix expansion
204+ "Unformatted" , # bazel v1.2.3
205+ "Unformatted" , # bazel v2.3.4
206+ None , # no name, bazel v1.2.3
207+ None , # no name, bazel v2.3.4
208+ "Formatted w/ Bazel v1.2.3 on pf1" ,
209+ "Formatted w/ Bazel v1.2.3 on pf2" ,
210+ "Formatted w/ Bazel v2.3.4 on pf1" ,
211+ "Formatted w/ Bazel v2.3.4 on pf2" ,
212+ ])
213+
174214
175215if __name__ == "__main__" :
176216 unittest .main ()
0 commit comments