blob: 0666da778bb00e8d698eba28dbf75a231be51d0c [file] [log] [blame]
Rupert Shuttleworthc5fa3062021-09-08 10:36:41 -04001// Copyright 2021 Google Inc. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package bp2build
16
17import (
18 "android/soong/android"
Sam Delmericocd1b80f2022-01-11 21:55:46 +000019 "android/soong/cc"
Rupert Shuttleworthc5fa3062021-09-08 10:36:41 -040020 "android/soong/genrule"
Sam Delmericocd1b80f2022-01-11 21:55:46 +000021 "android/soong/java"
22 "fmt"
Rupert Shuttleworthc5fa3062021-09-08 10:36:41 -040023 "testing"
24)
25
Liz Kammer78cfdaa2021-11-08 12:56:31 -050026func registerGenruleModuleTypes(ctx android.RegistrationContext) {
27 ctx.RegisterModuleType("genrule_defaults", func() android.Module { return genrule.DefaultsFactory() })
28}
29
30func runGenruleTestCase(t *testing.T, tc bp2buildTestCase) {
31 t.Helper()
32 (&tc).moduleTypeUnderTest = "genrule"
33 (&tc).moduleTypeUnderTestFactory = genrule.GenRuleFactory
Liz Kammer78cfdaa2021-11-08 12:56:31 -050034 runBp2BuildTestCase(t, registerGenruleModuleTypes, tc)
35}
36
Sam Delmericocd1b80f2022-01-11 21:55:46 +000037func otherGenruleBp(genruleTarget string) map[string]string {
38 return map[string]string{
39 "other/Android.bp": fmt.Sprintf(`%s {
Rupert Shuttleworthc5fa3062021-09-08 10:36:41 -040040 name: "foo.tool",
41 out: ["foo_tool.out"],
42 srcs: ["foo_tool.in"],
43 cmd: "cp $(in) $(out)",
44}
Sam Delmericocd1b80f2022-01-11 21:55:46 +000045%s {
Rupert Shuttleworthc5fa3062021-09-08 10:36:41 -040046 name: "other.tool",
47 out: ["other_tool.out"],
48 srcs: ["other_tool.in"],
49 cmd: "cp $(in) $(out)",
Sam Delmericocd1b80f2022-01-11 21:55:46 +000050}`, genruleTarget, genruleTarget),
51 }
52}
53
54func TestGenruleCliVariableReplacement(t *testing.T) {
55 testCases := []struct {
56 moduleType string
57 factory android.ModuleFactory
58 genDir string
59 }{
60 {
61 moduleType: "genrule",
62 factory: genrule.GenRuleFactory,
63 genDir: "$(GENDIR)",
64 },
65 {
66 moduleType: "cc_genrule",
67 factory: cc.GenRuleFactory,
68 genDir: "$(RULEDIR)",
69 },
70 {
71 moduleType: "java_genrule",
72 factory: java.GenRuleFactory,
73 genDir: "$(RULEDIR)",
74 },
75 {
76 moduleType: "java_genrule_host",
77 factory: java.GenRuleFactoryHost,
78 genDir: "$(RULEDIR)",
79 },
Rupert Shuttleworthc5fa3062021-09-08 10:36:41 -040080 }
81
Sam Delmericocd1b80f2022-01-11 21:55:46 +000082 bp := `%s {
Rupert Shuttleworthc5fa3062021-09-08 10:36:41 -040083 name: "foo.tool",
84 out: ["foo_tool.out"],
85 srcs: ["foo_tool.in"],
86 cmd: "cp $(in) $(out)",
Sam Delmericocd1b80f2022-01-11 21:55:46 +000087 bazel_module: { bp2build_available: false },
Rupert Shuttleworthc5fa3062021-09-08 10:36:41 -040088}
89
Sam Delmericocd1b80f2022-01-11 21:55:46 +000090%s {
Rupert Shuttleworthc5fa3062021-09-08 10:36:41 -040091 name: "foo",
92 out: ["foo.out"],
93 srcs: ["foo.in"],
94 tools: [":foo.tool"],
95 cmd: "$(location :foo.tool) --genDir=$(genDir) arg $(in) $(out)",
96 bazel_module: { bp2build_available: true },
Sam Delmericocd1b80f2022-01-11 21:55:46 +000097}`
98
99 for _, tc := range testCases {
100 expectedBazelTargets := []string{
101 makeBazelTarget("genrule", "foo", attrNameToString{
102 "cmd": fmt.Sprintf(`"$(location :foo.tool) --genDir=%s arg $(SRCS) $(OUTS)"`, tc.genDir),
103 "outs": `["foo.out"]`,
104 "srcs": `["foo.in"]`,
105 "tools": `[":foo.tool"]`,
106 }),
107 }
108
109 t.Run(tc.moduleType, func(t *testing.T) {
110 runBp2BuildTestCase(t, func(ctx android.RegistrationContext) {},
111 bp2buildTestCase{
112 moduleTypeUnderTest: tc.moduleType,
113 moduleTypeUnderTestFactory: tc.factory,
114 blueprint: fmt.Sprintf(bp, tc.moduleType, tc.moduleType),
115 expectedBazelTargets: expectedBazelTargets,
116 })
117 })
118 }
119}
120
121func TestGenruleLocationsLabel(t *testing.T) {
122 testCases := []struct {
123 moduleType string
124 factory android.ModuleFactory
125 }{
126 {
127 moduleType: "genrule",
128 factory: genrule.GenRuleFactory,
Rupert Shuttleworthc5fa3062021-09-08 10:36:41 -0400129 },
130 {
Sam Delmericocd1b80f2022-01-11 21:55:46 +0000131 moduleType: "cc_genrule",
132 factory: cc.GenRuleFactory,
133 },
134 {
135 moduleType: "java_genrule",
136 factory: java.GenRuleFactory,
137 },
138 {
139 moduleType: "java_genrule_host",
140 factory: java.GenRuleFactoryHost,
141 },
142 }
143
144 bp := `%s {
Rupert Shuttleworthc5fa3062021-09-08 10:36:41 -0400145 name: "foo.tools",
146 out: ["foo_tool.out", "foo_tool2.out"],
147 srcs: ["foo_tool.in"],
148 cmd: "cp $(in) $(out)",
149 bazel_module: { bp2build_available: true },
150}
151
Sam Delmericocd1b80f2022-01-11 21:55:46 +0000152%s {
Rupert Shuttleworthc5fa3062021-09-08 10:36:41 -0400153 name: "foo",
154 out: ["foo.out"],
155 srcs: ["foo.in"],
156 tools: [":foo.tools"],
157 cmd: "$(locations :foo.tools) -s $(out) $(in)",
158 bazel_module: { bp2build_available: true },
Sam Delmericocd1b80f2022-01-11 21:55:46 +0000159}`
160
161 expectedBazelTargets :=
162 []string{
163 makeBazelTarget("genrule", "foo", attrNameToString{
164 "cmd": `"$(locations :foo.tools) -s $(OUTS) $(SRCS)"`,
165 "outs": `["foo.out"]`,
166 "srcs": `["foo.in"]`,
167 "tools": `[":foo.tools"]`,
168 }),
169 makeBazelTarget("genrule", "foo.tools", attrNameToString{
170 "cmd": `"cp $(SRCS) $(OUTS)"`,
171 "outs": `[
Rupert Shuttleworthc5fa3062021-09-08 10:36:41 -0400172 "foo_tool.out",
173 "foo_tool2.out",
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500174 ]`,
Sam Delmericocd1b80f2022-01-11 21:55:46 +0000175 "srcs": `["foo_tool.in"]`,
176 }),
177 }
178
179 for _, tc := range testCases {
180 t.Run(tc.moduleType, func(t *testing.T) {
181 runBp2BuildTestCase(t, func(ctx android.RegistrationContext) {},
182 bp2buildTestCase{
183 moduleTypeUnderTest: tc.moduleType,
184 moduleTypeUnderTestFactory: tc.factory,
185 blueprint: fmt.Sprintf(bp, tc.moduleType, tc.moduleType),
186 expectedBazelTargets: expectedBazelTargets,
187 })
188 })
189 }
190}
191
192func TestGenruleLocationsAbsoluteLabel(t *testing.T) {
193 testCases := []struct {
194 moduleType string
195 factory android.ModuleFactory
196 }{
197 {
198 moduleType: "genrule",
199 factory: genrule.GenRuleFactory,
Rupert Shuttleworthc5fa3062021-09-08 10:36:41 -0400200 },
201 {
Sam Delmericocd1b80f2022-01-11 21:55:46 +0000202 moduleType: "cc_genrule",
203 factory: cc.GenRuleFactory,
204 },
205 {
206 moduleType: "java_genrule",
207 factory: java.GenRuleFactory,
208 },
209 {
210 moduleType: "java_genrule_host",
211 factory: java.GenRuleFactoryHost,
212 },
213 }
214
215 bp := `%s {
Rupert Shuttleworthc5fa3062021-09-08 10:36:41 -0400216 name: "foo",
217 out: ["foo.out"],
218 srcs: ["foo.in"],
219 tool_files: [":foo.tool"],
220 cmd: "$(locations :foo.tool) -s $(out) $(in)",
221 bazel_module: { bp2build_available: true },
Sam Delmericocd1b80f2022-01-11 21:55:46 +0000222}`
223
224 expectedBazelTargets := []string{
225 makeBazelTarget("genrule", "foo", attrNameToString{
226 "cmd": `"$(locations //other:foo.tool) -s $(OUTS) $(SRCS)"`,
227 "outs": `["foo.out"]`,
228 "srcs": `["foo.in"]`,
229 "tools": `["//other:foo.tool"]`,
230 }),
231 }
232
233 for _, tc := range testCases {
234 t.Run(tc.moduleType, func(t *testing.T) {
235 runBp2BuildTestCase(t, func(ctx android.RegistrationContext) {},
236 bp2buildTestCase{
237 moduleTypeUnderTest: tc.moduleType,
238 moduleTypeUnderTestFactory: tc.factory,
239 blueprint: fmt.Sprintf(bp, tc.moduleType),
240 expectedBazelTargets: expectedBazelTargets,
241 filesystem: otherGenruleBp(tc.moduleType),
242 })
243 })
244 }
245}
246
247func TestGenruleSrcsLocationsAbsoluteLabel(t *testing.T) {
248 testCases := []struct {
249 moduleType string
250 factory android.ModuleFactory
251 }{
252 {
253 moduleType: "genrule",
254 factory: genrule.GenRuleFactory,
Rupert Shuttleworthc5fa3062021-09-08 10:36:41 -0400255 },
256 {
Sam Delmericocd1b80f2022-01-11 21:55:46 +0000257 moduleType: "cc_genrule",
258 factory: cc.GenRuleFactory,
259 },
260 {
261 moduleType: "java_genrule",
262 factory: java.GenRuleFactory,
263 },
264 {
265 moduleType: "java_genrule_host",
266 factory: java.GenRuleFactoryHost,
267 },
268 }
269
270 bp := `%s {
Rupert Shuttleworthc5fa3062021-09-08 10:36:41 -0400271 name: "foo",
272 out: ["foo.out"],
273 srcs: [":other.tool"],
274 tool_files: [":foo.tool"],
275 cmd: "$(locations :foo.tool) -s $(out) $(location :other.tool)",
276 bazel_module: { bp2build_available: true },
Sam Delmericocd1b80f2022-01-11 21:55:46 +0000277}`
278
279 expectedBazelTargets := []string{
280 makeBazelTarget("genrule", "foo", attrNameToString{
281 "cmd": `"$(locations //other:foo.tool) -s $(OUTS) $(location //other:other.tool)"`,
282 "outs": `["foo.out"]`,
283 "srcs": `["//other:other.tool"]`,
284 "tools": `["//other:foo.tool"]`,
285 }),
286 }
287
288 for _, tc := range testCases {
289 t.Run(tc.moduleType, func(t *testing.T) {
290 runBp2BuildTestCase(t, func(ctx android.RegistrationContext) {},
291 bp2buildTestCase{
292 moduleTypeUnderTest: tc.moduleType,
293 moduleTypeUnderTestFactory: tc.factory,
294 blueprint: fmt.Sprintf(bp, tc.moduleType),
295 expectedBazelTargets: expectedBazelTargets,
296 filesystem: otherGenruleBp(tc.moduleType),
297 })
298 })
299 }
300}
301
302func TestGenruleLocationLabelShouldSubstituteFirstToolLabel(t *testing.T) {
303 testCases := []struct {
304 moduleType string
305 factory android.ModuleFactory
306 }{
307 {
308 moduleType: "genrule",
309 factory: genrule.GenRuleFactory,
Rupert Shuttleworthc5fa3062021-09-08 10:36:41 -0400310 },
311 {
Sam Delmericocd1b80f2022-01-11 21:55:46 +0000312 moduleType: "cc_genrule",
313 factory: cc.GenRuleFactory,
314 },
315 {
316 moduleType: "java_genrule",
317 factory: java.GenRuleFactory,
318 },
319 {
320 moduleType: "java_genrule_host",
321 factory: java.GenRuleFactoryHost,
322 },
323 }
324
325 bp := `%s {
Rupert Shuttleworthc5fa3062021-09-08 10:36:41 -0400326 name: "foo",
327 out: ["foo.out"],
328 srcs: ["foo.in"],
329 tool_files: [":foo.tool", ":other.tool"],
330 cmd: "$(location) -s $(out) $(in)",
331 bazel_module: { bp2build_available: true },
Sam Delmericocd1b80f2022-01-11 21:55:46 +0000332}`
333
334 expectedBazelTargets := []string{
335 makeBazelTarget("genrule", "foo", attrNameToString{
336 "cmd": `"$(location //other:foo.tool) -s $(OUTS) $(SRCS)"`,
337 "outs": `["foo.out"]`,
338 "srcs": `["foo.in"]`,
339 "tools": `[
Rupert Shuttleworthc5fa3062021-09-08 10:36:41 -0400340 "//other:foo.tool",
341 "//other:other.tool",
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500342 ]`,
Sam Delmericocd1b80f2022-01-11 21:55:46 +0000343 })}
344
345 for _, tc := range testCases {
346 t.Run(tc.moduleType, func(t *testing.T) {
347 runBp2BuildTestCase(t, func(ctx android.RegistrationContext) {},
348 bp2buildTestCase{
349 moduleTypeUnderTest: tc.moduleType,
350 moduleTypeUnderTestFactory: tc.factory,
351 blueprint: fmt.Sprintf(bp, tc.moduleType),
352 expectedBazelTargets: expectedBazelTargets,
353 filesystem: otherGenruleBp(tc.moduleType),
354 })
355 })
356 }
357}
358
359func TestGenruleLocationsLabelShouldSubstituteFirstToolLabel(t *testing.T) {
360 testCases := []struct {
361 moduleType string
362 factory android.ModuleFactory
363 }{
364 {
365 moduleType: "genrule",
366 factory: genrule.GenRuleFactory,
Rupert Shuttleworthc5fa3062021-09-08 10:36:41 -0400367 },
368 {
Sam Delmericocd1b80f2022-01-11 21:55:46 +0000369 moduleType: "cc_genrule",
370 factory: cc.GenRuleFactory,
371 },
372 {
373 moduleType: "java_genrule",
374 factory: java.GenRuleFactory,
375 },
376 {
377 moduleType: "java_genrule_host",
378 factory: java.GenRuleFactoryHost,
379 },
380 }
381
382 bp := `%s {
Rupert Shuttleworthc5fa3062021-09-08 10:36:41 -0400383 name: "foo",
384 out: ["foo.out"],
385 srcs: ["foo.in"],
Sam Delmericocd1b80f2022-01-11 21:55:46 +0000386 tool_files: [":foo.tool", ":other.tool"],
Rupert Shuttleworthc5fa3062021-09-08 10:36:41 -0400387 cmd: "$(locations) -s $(out) $(in)",
388 bazel_module: { bp2build_available: true },
Sam Delmericocd1b80f2022-01-11 21:55:46 +0000389}`
390
391 expectedBazelTargets := []string{
392 makeBazelTarget("genrule", "foo", attrNameToString{
393 "cmd": `"$(locations //other:foo.tool) -s $(OUTS) $(SRCS)"`,
394 "outs": `["foo.out"]`,
395 "srcs": `["foo.in"]`,
396 "tools": `[
Rupert Shuttleworthc5fa3062021-09-08 10:36:41 -0400397 "//other:foo.tool",
398 "//other:other.tool",
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500399 ]`,
Sam Delmericocd1b80f2022-01-11 21:55:46 +0000400 })}
401
402 for _, tc := range testCases {
403 t.Run(tc.moduleType, func(t *testing.T) {
404 runBp2BuildTestCase(t, func(ctx android.RegistrationContext) {},
405 bp2buildTestCase{
406 moduleTypeUnderTest: tc.moduleType,
407 moduleTypeUnderTestFactory: tc.factory,
408 blueprint: fmt.Sprintf(bp, tc.moduleType),
409 expectedBazelTargets: expectedBazelTargets,
410 filesystem: otherGenruleBp(tc.moduleType),
411 })
412 })
413 }
414}
415
416func TestGenruleWithoutToolsOrToolFiles(t *testing.T) {
417 testCases := []struct {
418 moduleType string
419 factory android.ModuleFactory
420 }{
421 {
422 moduleType: "genrule",
423 factory: genrule.GenRuleFactory,
Rupert Shuttleworthc5fa3062021-09-08 10:36:41 -0400424 },
425 {
Sam Delmericocd1b80f2022-01-11 21:55:46 +0000426 moduleType: "cc_genrule",
427 factory: cc.GenRuleFactory,
428 },
429 {
430 moduleType: "java_genrule",
431 factory: java.GenRuleFactory,
432 },
433 {
434 moduleType: "java_genrule_host",
435 factory: java.GenRuleFactoryHost,
436 },
437 }
438
439 bp := `%s {
Rupert Shuttleworthc5fa3062021-09-08 10:36:41 -0400440 name: "foo",
441 out: ["foo.out"],
442 srcs: ["foo.in"],
443 cmd: "cp $(in) $(out)",
444 bazel_module: { bp2build_available: true },
Sam Delmericocd1b80f2022-01-11 21:55:46 +0000445}`
Rupert Shuttleworthc5fa3062021-09-08 10:36:41 -0400446
Sam Delmericocd1b80f2022-01-11 21:55:46 +0000447 expectedBazelTargets := []string{
448 makeBazelTarget("genrule", "foo", attrNameToString{
449 "cmd": `"cp $(SRCS) $(OUTS)"`,
450 "outs": `["foo.out"]`,
451 "srcs": `["foo.in"]`,
452 })}
453
454 for _, tc := range testCases {
455 t.Run(tc.moduleType, func(t *testing.T) {
456 runBp2BuildTestCase(t, func(ctx android.RegistrationContext) {},
457 bp2buildTestCase{
458 moduleTypeUnderTest: tc.moduleType,
459 moduleTypeUnderTestFactory: tc.factory,
460 blueprint: fmt.Sprintf(bp, tc.moduleType),
461 expectedBazelTargets: expectedBazelTargets,
462 })
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500463 })
Rupert Shuttleworthc5fa3062021-09-08 10:36:41 -0400464 }
465}
466
Sam Delmericocd1b80f2022-01-11 21:55:46 +0000467func TestGenruleBp2BuildInlinesDefaults(t *testing.T) {
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500468 testCases := []bp2buildTestCase{
Rupert Shuttleworthc5fa3062021-09-08 10:36:41 -0400469 {
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500470 description: "genrule applies properties from a genrule_defaults dependency if not specified",
471 blueprint: `genrule_defaults {
Rupert Shuttleworthc5fa3062021-09-08 10:36:41 -0400472 name: "gen_defaults",
473 cmd: "do-something $(in) $(out)",
474}
475genrule {
476 name: "gen",
477 out: ["out"],
478 srcs: ["in1"],
479 defaults: ["gen_defaults"],
480 bazel_module: { bp2build_available: true },
481}
482`,
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500483 expectedBazelTargets: []string{
484 makeBazelTarget("genrule", "gen", attrNameToString{
485 "cmd": `"do-something $(SRCS) $(OUTS)"`,
486 "outs": `["out"]`,
487 "srcs": `["in1"]`,
488 }),
489 },
Rupert Shuttleworthc5fa3062021-09-08 10:36:41 -0400490 },
491 {
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500492 description: "genrule does merges properties from a genrule_defaults dependency, latest-first",
493 blueprint: `genrule_defaults {
Rupert Shuttleworthc5fa3062021-09-08 10:36:41 -0400494 name: "gen_defaults",
495 out: ["out-from-defaults"],
496 srcs: ["in-from-defaults"],
497 cmd: "cmd-from-defaults",
498}
499genrule {
500 name: "gen",
501 out: ["out"],
502 srcs: ["in1"],
503 defaults: ["gen_defaults"],
504 cmd: "do-something $(in) $(out)",
505 bazel_module: { bp2build_available: true },
506}
507`,
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500508 expectedBazelTargets: []string{
509 makeBazelTarget("genrule", "gen", attrNameToString{
510 "cmd": `"do-something $(SRCS) $(OUTS)"`,
511 "outs": `[
Rupert Shuttleworthc5fa3062021-09-08 10:36:41 -0400512 "out-from-defaults",
513 "out",
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500514 ]`,
515 "srcs": `[
Rupert Shuttleworthc5fa3062021-09-08 10:36:41 -0400516 "in-from-defaults",
517 "in1",
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500518 ]`,
519 }),
520 },
Rupert Shuttleworthc5fa3062021-09-08 10:36:41 -0400521 },
522 {
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500523 description: "genrule applies properties from list of genrule_defaults",
524 blueprint: `genrule_defaults {
Rupert Shuttleworthc5fa3062021-09-08 10:36:41 -0400525 name: "gen_defaults1",
526 cmd: "cp $(in) $(out)",
527}
528
529genrule_defaults {
530 name: "gen_defaults2",
531 srcs: ["in1"],
532}
533
534genrule {
535 name: "gen",
536 out: ["out"],
537 defaults: ["gen_defaults1", "gen_defaults2"],
538 bazel_module: { bp2build_available: true },
539}
540`,
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500541 expectedBazelTargets: []string{
542 makeBazelTarget("genrule", "gen", attrNameToString{
543 "cmd": `"cp $(SRCS) $(OUTS)"`,
544 "outs": `["out"]`,
545 "srcs": `["in1"]`,
546 }),
547 },
Rupert Shuttleworthc5fa3062021-09-08 10:36:41 -0400548 },
549 {
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500550 description: "genrule applies properties from genrule_defaults transitively",
551 blueprint: `genrule_defaults {
Rupert Shuttleworthc5fa3062021-09-08 10:36:41 -0400552 name: "gen_defaults1",
553 defaults: ["gen_defaults2"],
554 cmd: "cmd1 $(in) $(out)", // overrides gen_defaults2's cmd property value.
555}
556
557genrule_defaults {
558 name: "gen_defaults2",
559 defaults: ["gen_defaults3"],
560 cmd: "cmd2 $(in) $(out)",
561 out: ["out-from-2"],
562 srcs: ["in1"],
563}
564
565genrule_defaults {
566 name: "gen_defaults3",
567 out: ["out-from-3"],
568 srcs: ["srcs-from-3"],
569}
570
571genrule {
572 name: "gen",
573 out: ["out"],
574 defaults: ["gen_defaults1"],
575 bazel_module: { bp2build_available: true },
576}
577`,
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500578 expectedBazelTargets: []string{
579 makeBazelTarget("genrule", "gen", attrNameToString{
580 "cmd": `"cmd1 $(SRCS) $(OUTS)"`,
581 "outs": `[
Rupert Shuttleworthc5fa3062021-09-08 10:36:41 -0400582 "out-from-3",
583 "out-from-2",
584 "out",
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500585 ]`,
586 "srcs": `[
Rupert Shuttleworthc5fa3062021-09-08 10:36:41 -0400587 "srcs-from-3",
588 "in1",
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500589 ]`,
590 }),
591 },
Rupert Shuttleworthc5fa3062021-09-08 10:36:41 -0400592 },
593 }
594
Rupert Shuttleworthc5fa3062021-09-08 10:36:41 -0400595 for _, testCase := range testCases {
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500596 t.Run(testCase.description, func(t *testing.T) {
597 runGenruleTestCase(t, testCase)
598 })
Rupert Shuttleworthc5fa3062021-09-08 10:36:41 -0400599 }
600}