blob: ecfb008251b0edbbc251102f4460ddc915a3889f [file] [log] [blame]
Jooyung Han12df5fb2019-07-11 16:18:47 +09001// Copyright 2019 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 android
16
17import (
Jingwen Chen40fd90a2020-06-15 05:24:19 +000018 "fmt"
Jooyung Han12df5fb2019-07-11 16:18:47 +090019 "io"
20 "reflect"
Dan Willemsendef7b5d2021-10-17 00:22:33 -070021 "runtime"
Paul Duffin8b0349c2020-11-26 14:33:21 +000022 "strings"
Jooyung Han12df5fb2019-07-11 16:18:47 +090023 "testing"
Paul Duffin62269492020-11-26 20:18:42 +000024
25 "github.com/google/blueprint/proptools"
Jooyung Han12df5fb2019-07-11 16:18:47 +090026)
27
28type customModule struct {
29 ModuleBase
Paul Duffin62269492020-11-26 20:18:42 +000030
31 properties struct {
32 Default_dist_files *string
33 Dist_output_file *bool
34 }
35
36 data AndroidMkData
37 distFiles TaggedDistFiles
38 outputFile OptionalPath
Paul Duffin74f05592020-11-25 16:37:46 +000039
40 // The paths that will be used as the default dist paths if no tag is
41 // specified.
42 defaultDistPaths Paths
Jooyung Han12df5fb2019-07-11 16:18:47 +090043}
44
Paul Duffin62269492020-11-26 20:18:42 +000045const (
46 defaultDistFiles_None = "none"
47 defaultDistFiles_Default = "default"
48 defaultDistFiles_Tagged = "tagged"
49)
50
Jooyung Han12df5fb2019-07-11 16:18:47 +090051func (m *customModule) GenerateAndroidBuildActions(ctx ModuleContext) {
Paul Duffin62269492020-11-26 20:18:42 +000052
53 // If the dist_output_file: true then create an output file that is stored in
54 // the OutputFile property of the AndroidMkEntry.
55 if proptools.BoolDefault(m.properties.Dist_output_file, true) {
Paul Duffin74f05592020-11-25 16:37:46 +000056 path := PathForTesting("dist-output-file.out")
57 m.outputFile = OptionalPathForPath(path)
58
59 // Previous code would prioritize the DistFiles property over the OutputFile
60 // property in AndroidMkEntry when determining the default dist paths.
61 // Setting this first allows it to be overridden based on the
62 // default_dist_files setting replicating that previous behavior.
63 m.defaultDistPaths = Paths{path}
Paul Duffin62269492020-11-26 20:18:42 +000064 }
65
66 // Based on the setting of the default_dist_files property possibly create a
67 // TaggedDistFiles structure that will be stored in the DistFiles property of
68 // the AndroidMkEntry.
69 defaultDistFiles := proptools.StringDefault(m.properties.Default_dist_files, defaultDistFiles_Tagged)
70 switch defaultDistFiles {
71 case defaultDistFiles_None:
72 // Do nothing
73
74 case defaultDistFiles_Default:
Paul Duffin74f05592020-11-25 16:37:46 +000075 path := PathForTesting("default-dist.out")
76 m.defaultDistPaths = Paths{path}
77 m.distFiles = MakeDefaultDistFiles(path)
Paul Duffin62269492020-11-26 20:18:42 +000078
79 case defaultDistFiles_Tagged:
Paul Duffin74f05592020-11-25 16:37:46 +000080 // Module types that set AndroidMkEntry.DistFiles to the result of calling
81 // GenerateTaggedDistFiles(ctx) relied on no tag being treated as "" which
82 // meant that the default dist paths would be whatever was returned by
83 // OutputFiles(""). In order to preserve that behavior when treating no tag
84 // as being equal to DefaultDistTag this ensures that
85 // OutputFiles(DefaultDistTag) will return the same as OutputFiles("").
86 m.defaultDistPaths = PathsForTesting("one.out")
87
88 // This must be called after setting defaultDistPaths/outputFile as
89 // GenerateTaggedDistFiles calls into OutputFiles(tag) which may use those
90 // fields.
Paul Duffin62269492020-11-26 20:18:42 +000091 m.distFiles = m.GenerateTaggedDistFiles(ctx)
92 }
Jooyung Han12df5fb2019-07-11 16:18:47 +090093}
94
95func (m *customModule) AndroidMk() AndroidMkData {
96 return AndroidMkData{
97 Custom: func(w io.Writer, name, prefix, moduleDir string, data AndroidMkData) {
98 m.data = data
99 },
100 }
101}
102
Jingwen Chen40fd90a2020-06-15 05:24:19 +0000103func (m *customModule) OutputFiles(tag string) (Paths, error) {
104 switch tag {
Paul Duffin74f05592020-11-25 16:37:46 +0000105 case DefaultDistTag:
106 if m.defaultDistPaths != nil {
107 return m.defaultDistPaths, nil
108 } else {
109 return nil, fmt.Errorf("default dist tag is not available")
110 }
Jingwen Chen40fd90a2020-06-15 05:24:19 +0000111 case "":
112 return PathsForTesting("one.out"), nil
113 case ".multiple":
114 return PathsForTesting("two.out", "three/four.out"), nil
Jingwen Chen84811862020-07-21 11:32:19 +0000115 case ".another-tag":
116 return PathsForTesting("another.out"), nil
Jingwen Chen40fd90a2020-06-15 05:24:19 +0000117 default:
118 return nil, fmt.Errorf("unsupported module reference tag %q", tag)
119 }
120}
121
122func (m *customModule) AndroidMkEntries() []AndroidMkEntries {
123 return []AndroidMkEntries{
124 {
Paul Duffin62269492020-11-26 20:18:42 +0000125 Class: "CUSTOM_MODULE",
126 DistFiles: m.distFiles,
127 OutputFile: m.outputFile,
Jingwen Chen40fd90a2020-06-15 05:24:19 +0000128 },
129 }
130}
131
Jooyung Han12df5fb2019-07-11 16:18:47 +0900132func customModuleFactory() Module {
133 module := &customModule{}
Paul Duffin62269492020-11-26 20:18:42 +0000134
135 module.AddProperties(&module.properties)
136
Jooyung Han12df5fb2019-07-11 16:18:47 +0900137 InitAndroidModule(module)
138 return module
139}
140
Colin Crossaa255532020-07-03 13:18:24 -0700141// buildContextAndCustomModuleFoo creates a config object, processes the supplied
Paul Duffin103aaae2020-11-26 17:36:46 +0000142// bp module and then returns the config and the custom module called "foo".
Colin Crossaa255532020-07-03 13:18:24 -0700143func buildContextAndCustomModuleFoo(t *testing.T, bp string) (*TestContext, *customModule) {
Paul Duffin103aaae2020-11-26 17:36:46 +0000144 t.Helper()
Paul Duffin30ac3e72021-03-20 00:36:14 +0000145 result := GroupFixturePreparers(
Paul Duffin9ca14c12021-03-16 17:30:13 +0000146 // Enable androidmk Singleton
147 PrepareForTestWithAndroidMk,
148 FixtureRegisterWithContext(func(ctx RegistrationContext) {
149 ctx.RegisterModuleType("custom", customModuleFactory)
150 }),
151 FixtureWithRootAndroidBp(bp),
Paul Duffin30ac3e72021-03-20 00:36:14 +0000152 ).RunTest(t)
Colin Cross98be1bb2019-12-13 20:41:13 -0800153
Paul Duffin9ca14c12021-03-16 17:30:13 +0000154 module := result.ModuleForTests("foo", "").Module().(*customModule)
155 return result.TestContext, module
Paul Duffin103aaae2020-11-26 17:36:46 +0000156}
157
158func TestAndroidMkSingleton_PassesUpdatedAndroidMkDataToCustomCallback(t *testing.T) {
Dan Willemsendef7b5d2021-10-17 00:22:33 -0700159 if runtime.GOOS == "darwin" {
160 // Device modules are not exported on Mac, so this test doesn't work.
161 t.SkipNow()
162 }
163
Paul Duffin103aaae2020-11-26 17:36:46 +0000164 bp := `
165 custom {
166 name: "foo",
167 required: ["bar"],
168 host_required: ["baz"],
169 target_required: ["qux"],
170 }
171 `
172
Colin Crossaa255532020-07-03 13:18:24 -0700173 _, m := buildContextAndCustomModuleFoo(t, bp)
Jooyung Han12df5fb2019-07-11 16:18:47 +0900174
175 assertEqual := func(expected interface{}, actual interface{}) {
176 if !reflect.DeepEqual(expected, actual) {
177 t.Errorf("%q expected, but got %q", expected, actual)
178 }
179 }
180 assertEqual([]string{"bar"}, m.data.Required)
181 assertEqual([]string{"baz"}, m.data.Host_required)
182 assertEqual([]string{"qux"}, m.data.Target_required)
183}
Jingwen Chen40fd90a2020-06-15 05:24:19 +0000184
Paul Duffin8b0349c2020-11-26 14:33:21 +0000185func TestGenerateDistContributionsForMake(t *testing.T) {
186 dc := &distContributions{
187 copiesForGoals: []*copiesForGoals{
188 {
189 goals: "my_goal",
190 copies: []distCopy{
191 distCopyForTest("one.out", "one.out"),
192 distCopyForTest("two.out", "other.out"),
193 },
194 },
195 },
196 }
197
198 makeOutput := generateDistContributionsForMake(dc)
199
200 assertStringEquals(t, `.PHONY: my_goal
201$(call dist-for-goals,my_goal,one.out:one.out)
202$(call dist-for-goals,my_goal,two.out:other.out)
203`, strings.Join(makeOutput, ""))
204}
205
Jingwen Chen40fd90a2020-06-15 05:24:19 +0000206func TestGetDistForGoals(t *testing.T) {
Paul Duffind83988d2020-11-26 17:29:35 +0000207 bp := `
Jingwen Chen40fd90a2020-06-15 05:24:19 +0000208 custom {
209 name: "foo",
210 dist: {
211 targets: ["my_goal", "my_other_goal"],
212 tag: ".multiple",
213 },
214 dists: [
215 {
216 targets: ["my_second_goal"],
217 tag: ".multiple",
218 },
219 {
220 targets: ["my_third_goal"],
221 dir: "test/dir",
222 },
223 {
224 targets: ["my_fourth_goal"],
225 suffix: ".suffix",
226 },
227 {
228 targets: ["my_fifth_goal"],
229 dest: "new-name",
230 },
231 {
232 targets: ["my_sixth_goal"],
233 dest: "new-name",
234 dir: "some/dir",
235 suffix: ".suffix",
236 },
237 ],
238 }
Paul Duffind83988d2020-11-26 17:29:35 +0000239 `
240
241 expectedAndroidMkLines := []string{
242 ".PHONY: my_second_goal\n",
243 "$(call dist-for-goals,my_second_goal,two.out:two.out)\n",
244 "$(call dist-for-goals,my_second_goal,three/four.out:four.out)\n",
245 ".PHONY: my_third_goal\n",
246 "$(call dist-for-goals,my_third_goal,one.out:test/dir/one.out)\n",
247 ".PHONY: my_fourth_goal\n",
248 "$(call dist-for-goals,my_fourth_goal,one.out:one.suffix.out)\n",
249 ".PHONY: my_fifth_goal\n",
250 "$(call dist-for-goals,my_fifth_goal,one.out:new-name)\n",
251 ".PHONY: my_sixth_goal\n",
252 "$(call dist-for-goals,my_sixth_goal,one.out:some/dir/new-name.suffix)\n",
253 ".PHONY: my_goal my_other_goal\n",
254 "$(call dist-for-goals,my_goal my_other_goal,two.out:two.out)\n",
255 "$(call dist-for-goals,my_goal my_other_goal,three/four.out:four.out)\n",
Jingwen Chen40fd90a2020-06-15 05:24:19 +0000256 }
257
Colin Crossaa255532020-07-03 13:18:24 -0700258 ctx, module := buildContextAndCustomModuleFoo(t, bp)
259 entries := AndroidMkEntriesForTest(t, ctx, module)
Paul Duffind83988d2020-11-26 17:29:35 +0000260 if len(entries) != 1 {
261 t.Errorf("Expected a single AndroidMk entry, got %d", len(entries))
262 }
263 androidMkLines := entries[0].GetDistForGoals(module)
Jingwen Chen40fd90a2020-06-15 05:24:19 +0000264
Paul Duffind83988d2020-11-26 17:29:35 +0000265 if len(androidMkLines) != len(expectedAndroidMkLines) {
266 t.Errorf(
267 "Expected %d AndroidMk lines, got %d:\n%v",
268 len(expectedAndroidMkLines),
269 len(androidMkLines),
270 androidMkLines,
271 )
272 }
273 for idx, line := range androidMkLines {
274 expectedLine := expectedAndroidMkLines[idx]
275 if line != expectedLine {
276 t.Errorf(
277 "Expected AndroidMk line to be '%s', got '%s'",
278 expectedLine,
279 line,
280 )
281 }
Jingwen Chen40fd90a2020-06-15 05:24:19 +0000282 }
283}
Paul Duffin8b0349c2020-11-26 14:33:21 +0000284
285func distCopyForTest(from, to string) distCopy {
286 return distCopy{PathForTesting(from), to}
287}
288
289func TestGetDistContributions(t *testing.T) {
290 compareContributions := func(d1 *distContributions, d2 *distContributions) error {
291 if d1 == nil || d2 == nil {
292 if d1 != d2 {
293 return fmt.Errorf("pointer mismatch, expected both to be nil but they were %p and %p", d1, d2)
294 } else {
295 return nil
296 }
297 }
298 if expected, actual := len(d1.copiesForGoals), len(d2.copiesForGoals); expected != actual {
299 return fmt.Errorf("length mismatch, expected %d found %d", expected, actual)
300 }
301
302 for i, copies1 := range d1.copiesForGoals {
303 copies2 := d2.copiesForGoals[i]
304 if expected, actual := copies1.goals, copies2.goals; expected != actual {
305 return fmt.Errorf("goals mismatch at position %d: expected %q found %q", i, expected, actual)
306 }
307
308 if expected, actual := len(copies1.copies), len(copies2.copies); expected != actual {
309 return fmt.Errorf("length mismatch in copy instructions at position %d, expected %d found %d", i, expected, actual)
310 }
311
312 for j, c1 := range copies1.copies {
313 c2 := copies2.copies[j]
314 if expected, actual := NormalizePathForTesting(c1.from), NormalizePathForTesting(c2.from); expected != actual {
315 return fmt.Errorf("paths mismatch at position %d.%d: expected %q found %q", i, j, expected, actual)
316 }
317
318 if expected, actual := c1.dest, c2.dest; expected != actual {
319 return fmt.Errorf("dest mismatch at position %d.%d: expected %q found %q", i, j, expected, actual)
320 }
321 }
322 }
323
324 return nil
325 }
326
327 formatContributions := func(d *distContributions) string {
328 buf := &strings.Builder{}
329 if d == nil {
330 fmt.Fprint(buf, "nil")
331 } else {
332 for _, copiesForGoals := range d.copiesForGoals {
333 fmt.Fprintf(buf, " Goals: %q {\n", copiesForGoals.goals)
334 for _, c := range copiesForGoals.copies {
335 fmt.Fprintf(buf, " %s -> %s\n", NormalizePathForTesting(c.from), c.dest)
336 }
337 fmt.Fprint(buf, " }\n")
338 }
339 }
340 return buf.String()
341 }
342
343 testHelper := func(t *testing.T, name, bp string, expectedContributions *distContributions) {
344 t.Helper()
345 t.Run(name, func(t *testing.T) {
346 t.Helper()
347
Colin Crossaa255532020-07-03 13:18:24 -0700348 ctx, module := buildContextAndCustomModuleFoo(t, bp)
349 entries := AndroidMkEntriesForTest(t, ctx, module)
Paul Duffin8b0349c2020-11-26 14:33:21 +0000350 if len(entries) != 1 {
351 t.Errorf("Expected a single AndroidMk entry, got %d", len(entries))
352 }
353 distContributions := entries[0].getDistContributions(module)
354
355 if err := compareContributions(expectedContributions, distContributions); err != nil {
356 t.Errorf("%s\nExpected Contributions\n%sActualContributions\n%s",
357 err,
358 formatContributions(expectedContributions),
359 formatContributions(distContributions))
360 }
361 })
362 }
363
364 testHelper(t, "dist-without-tag", `
365 custom {
366 name: "foo",
367 dist: {
368 targets: ["my_goal"]
369 }
370 }
371`,
372 &distContributions{
373 copiesForGoals: []*copiesForGoals{
374 {
375 goals: "my_goal",
376 copies: []distCopy{
377 distCopyForTest("one.out", "one.out"),
378 },
379 },
380 },
381 })
382
383 testHelper(t, "dist-with-tag", `
384 custom {
385 name: "foo",
386 dist: {
387 targets: ["my_goal"],
388 tag: ".another-tag",
389 }
390 }
391`,
392 &distContributions{
393 copiesForGoals: []*copiesForGoals{
394 {
395 goals: "my_goal",
396 copies: []distCopy{
397 distCopyForTest("another.out", "another.out"),
398 },
399 },
400 },
401 })
402
403 testHelper(t, "dists-with-tag", `
404 custom {
405 name: "foo",
406 dists: [
407 {
408 targets: ["my_goal"],
409 tag: ".another-tag",
410 },
411 ],
412 }
413`,
414 &distContributions{
415 copiesForGoals: []*copiesForGoals{
416 {
417 goals: "my_goal",
418 copies: []distCopy{
419 distCopyForTest("another.out", "another.out"),
420 },
421 },
422 },
423 })
424
425 testHelper(t, "multiple-dists-with-and-without-tag", `
426 custom {
427 name: "foo",
428 dists: [
429 {
430 targets: ["my_goal"],
431 },
432 {
433 targets: ["my_second_goal", "my_third_goal"],
434 },
435 ],
436 }
437`,
438 &distContributions{
439 copiesForGoals: []*copiesForGoals{
440 {
441 goals: "my_goal",
442 copies: []distCopy{
443 distCopyForTest("one.out", "one.out"),
444 },
445 },
446 {
447 goals: "my_second_goal my_third_goal",
448 copies: []distCopy{
449 distCopyForTest("one.out", "one.out"),
450 },
451 },
452 },
453 })
454
455 testHelper(t, "dist-plus-dists-without-tags", `
456 custom {
457 name: "foo",
458 dist: {
459 targets: ["my_goal"],
460 },
461 dists: [
462 {
463 targets: ["my_second_goal", "my_third_goal"],
464 },
465 ],
466 }
467`,
468 &distContributions{
469 copiesForGoals: []*copiesForGoals{
470 {
471 goals: "my_second_goal my_third_goal",
472 copies: []distCopy{
473 distCopyForTest("one.out", "one.out"),
474 },
475 },
476 {
477 goals: "my_goal",
478 copies: []distCopy{
479 distCopyForTest("one.out", "one.out"),
480 },
481 },
482 },
483 })
484
485 testHelper(t, "dist-plus-dists-with-tags", `
486 custom {
487 name: "foo",
488 dist: {
489 targets: ["my_goal", "my_other_goal"],
490 tag: ".multiple",
491 },
492 dists: [
493 {
494 targets: ["my_second_goal"],
495 tag: ".multiple",
496 },
497 {
498 targets: ["my_third_goal"],
499 dir: "test/dir",
500 },
501 {
502 targets: ["my_fourth_goal"],
503 suffix: ".suffix",
504 },
505 {
506 targets: ["my_fifth_goal"],
507 dest: "new-name",
508 },
509 {
510 targets: ["my_sixth_goal"],
511 dest: "new-name",
512 dir: "some/dir",
513 suffix: ".suffix",
514 },
515 ],
516 }
517`,
518 &distContributions{
519 copiesForGoals: []*copiesForGoals{
520 {
521 goals: "my_second_goal",
522 copies: []distCopy{
523 distCopyForTest("two.out", "two.out"),
524 distCopyForTest("three/four.out", "four.out"),
525 },
526 },
527 {
528 goals: "my_third_goal",
529 copies: []distCopy{
530 distCopyForTest("one.out", "test/dir/one.out"),
531 },
532 },
533 {
534 goals: "my_fourth_goal",
535 copies: []distCopy{
536 distCopyForTest("one.out", "one.suffix.out"),
537 },
538 },
539 {
540 goals: "my_fifth_goal",
541 copies: []distCopy{
542 distCopyForTest("one.out", "new-name"),
543 },
544 },
545 {
546 goals: "my_sixth_goal",
547 copies: []distCopy{
548 distCopyForTest("one.out", "some/dir/new-name.suffix"),
549 },
550 },
551 {
552 goals: "my_goal my_other_goal",
553 copies: []distCopy{
554 distCopyForTest("two.out", "two.out"),
555 distCopyForTest("three/four.out", "four.out"),
556 },
557 },
558 },
559 })
Paul Duffin62269492020-11-26 20:18:42 +0000560
561 // The above test the default values of default_dist_files and use_output_file.
562
563 // The following tests explicitly test the different combinations of those settings.
564 testHelper(t, "tagged-dist-files-no-output", `
565 custom {
566 name: "foo",
567 default_dist_files: "tagged",
568 dist_output_file: false,
569 dists: [
570 {
571 targets: ["my_goal"],
572 },
573 {
574 targets: ["my_goal"],
575 tag: ".multiple",
576 },
577 ],
578 }
579`, &distContributions{
580 copiesForGoals: []*copiesForGoals{
581 {
582 goals: "my_goal",
583 copies: []distCopy{
584 distCopyForTest("one.out", "one.out"),
585 },
586 },
587 {
588 goals: "my_goal",
589 copies: []distCopy{
590 distCopyForTest("two.out", "two.out"),
591 distCopyForTest("three/four.out", "four.out"),
592 },
593 },
594 },
595 })
596
597 testHelper(t, "default-dist-files-no-output", `
598 custom {
599 name: "foo",
600 default_dist_files: "default",
601 dist_output_file: false,
602 dists: [
603 {
604 targets: ["my_goal"],
605 },
Paul Duffin62269492020-11-26 20:18:42 +0000606 {
607 targets: ["my_goal"],
608 tag: ".multiple",
609 },
610 ],
611 }
612`, &distContributions{
613 copiesForGoals: []*copiesForGoals{
614 {
615 goals: "my_goal",
616 copies: []distCopy{
617 distCopyForTest("default-dist.out", "default-dist.out"),
618 },
619 },
Paul Duffinaf970a22020-11-23 23:32:56 +0000620 {
621 goals: "my_goal",
622 copies: []distCopy{
623 distCopyForTest("two.out", "two.out"),
624 distCopyForTest("three/four.out", "four.out"),
625 },
626 },
Paul Duffin62269492020-11-26 20:18:42 +0000627 },
628 })
629
630 testHelper(t, "no-dist-files-no-output", `
631 custom {
632 name: "foo",
633 default_dist_files: "none",
634 dist_output_file: false,
635 dists: [
636 // The following is silently ignored because there is not default file
637 // in either the dist files or the output file.
638 {
639 targets: ["my_goal"],
640 },
Paul Duffin62269492020-11-26 20:18:42 +0000641 {
642 targets: ["my_goal"],
643 tag: ".multiple",
644 },
645 ],
646 }
Paul Duffinaf970a22020-11-23 23:32:56 +0000647`, &distContributions{
648 copiesForGoals: []*copiesForGoals{
649 {
650 goals: "my_goal",
651 copies: []distCopy{
652 distCopyForTest("two.out", "two.out"),
653 distCopyForTest("three/four.out", "four.out"),
654 },
655 },
656 },
657 })
Paul Duffin62269492020-11-26 20:18:42 +0000658
659 testHelper(t, "tagged-dist-files-default-output", `
660 custom {
661 name: "foo",
662 default_dist_files: "tagged",
663 dist_output_file: true,
664 dists: [
665 {
666 targets: ["my_goal"],
667 },
668 {
669 targets: ["my_goal"],
670 tag: ".multiple",
671 },
672 ],
673 }
674`, &distContributions{
675 copiesForGoals: []*copiesForGoals{
676 {
677 goals: "my_goal",
678 copies: []distCopy{
679 distCopyForTest("one.out", "one.out"),
680 },
681 },
682 {
683 goals: "my_goal",
684 copies: []distCopy{
685 distCopyForTest("two.out", "two.out"),
686 distCopyForTest("three/four.out", "four.out"),
687 },
688 },
689 },
690 })
691
692 testHelper(t, "default-dist-files-default-output", `
693 custom {
694 name: "foo",
695 default_dist_files: "default",
696 dist_output_file: true,
697 dists: [
698 {
699 targets: ["my_goal"],
700 },
Paul Duffin62269492020-11-26 20:18:42 +0000701 {
702 targets: ["my_goal"],
703 tag: ".multiple",
704 },
705 ],
706 }
707`, &distContributions{
708 copiesForGoals: []*copiesForGoals{
709 {
710 goals: "my_goal",
711 copies: []distCopy{
712 distCopyForTest("default-dist.out", "default-dist.out"),
713 },
714 },
Paul Duffinaf970a22020-11-23 23:32:56 +0000715 {
716 goals: "my_goal",
717 copies: []distCopy{
718 distCopyForTest("two.out", "two.out"),
719 distCopyForTest("three/four.out", "four.out"),
720 },
721 },
Paul Duffin62269492020-11-26 20:18:42 +0000722 },
723 })
724
725 testHelper(t, "no-dist-files-default-output", `
726 custom {
727 name: "foo",
728 default_dist_files: "none",
729 dist_output_file: true,
730 dists: [
731 {
732 targets: ["my_goal"],
733 },
Paul Duffin62269492020-11-26 20:18:42 +0000734 {
735 targets: ["my_goal"],
736 tag: ".multiple",
737 },
738 ],
739 }
740`, &distContributions{
741 copiesForGoals: []*copiesForGoals{
742 {
743 goals: "my_goal",
744 copies: []distCopy{
745 distCopyForTest("dist-output-file.out", "dist-output-file.out"),
746 },
747 },
Paul Duffinaf970a22020-11-23 23:32:56 +0000748 {
749 goals: "my_goal",
750 copies: []distCopy{
751 distCopyForTest("two.out", "two.out"),
752 distCopyForTest("three/four.out", "four.out"),
753 },
754 },
Paul Duffin62269492020-11-26 20:18:42 +0000755 },
756 })
Paul Duffin8b0349c2020-11-26 14:33:21 +0000757}