(t *testing.T)
| 730 | } |
| 731 | |
| 732 | func TestBuildExceptFileCommaFlags(t *testing.T) { |
| 733 | c := &BuildCommand{ |
| 734 | Meta: TestMetaFile(t), |
| 735 | } |
| 736 | tc := []struct { |
| 737 | name string |
| 738 | args []string |
| 739 | expectedFiles []string |
| 740 | buildNotExpectedFiles []string |
| 741 | postProcNotExpectedFiles []string |
| 742 | }{ |
| 743 | { |
| 744 | name: "JSON: except build and post-processor", |
| 745 | args: []string{ |
| 746 | "-parallel-builds=1", |
| 747 | "-except=chocolate,vanilla,tomato", |
| 748 | filepath.Join(testFixture("build-only"), "template.json"), |
| 749 | }, |
| 750 | expectedFiles: []string{"apple.txt", "cherry.txt", "peach.txt"}, |
| 751 | buildNotExpectedFiles: []string{"chocolate.txt", "vanilla.txt", "tomato.txt", "unnamed.txt"}, |
| 752 | postProcNotExpectedFiles: []string{"pear.txt, banana.txt"}, |
| 753 | }, |
| 754 | { |
| 755 | name: "HCL2: except build and post-processor", |
| 756 | args: []string{ |
| 757 | "-parallel-builds=1", |
| 758 | "-except=file.chocolate,file.vanilla,tomato", |
| 759 | filepath.Join(testFixture("build-only"), "template.pkr.hcl"), |
| 760 | }, |
| 761 | expectedFiles: []string{"apple.txt", "cherry.txt", "peach.txt"}, |
| 762 | buildNotExpectedFiles: []string{"chocolate.txt", "vanilla.txt", "tomato.txt", "unnamed.txt"}, |
| 763 | postProcNotExpectedFiles: []string{"pear.txt, banana.txt"}, |
| 764 | }, |
| 765 | { |
| 766 | name: "HCL2-JSON: except build and post-processor", |
| 767 | args: []string{ |
| 768 | "-parallel-builds=1", |
| 769 | "-except=file.chocolate,file.vanilla,tomato", |
| 770 | filepath.Join(testFixture("build-only"), "template.pkr.json"), |
| 771 | }, |
| 772 | expectedFiles: []string{"apple.txt", "cherry.txt", "peach.txt"}, |
| 773 | buildNotExpectedFiles: []string{"chocolate.txt", "vanilla.txt", "tomato.txt", "unnamed.txt"}, |
| 774 | postProcNotExpectedFiles: []string{"pear.txt, banana.txt"}, |
| 775 | }, |
| 776 | } |
| 777 | |
| 778 | for _, tt := range tc { |
| 779 | t.Run(tt.name, func(t *testing.T) { |
| 780 | defer cleanup() |
| 781 | |
| 782 | if code := c.Run(tt.args); code != 0 { |
| 783 | fatalCommand(t, c.Meta) |
| 784 | } |
| 785 | |
| 786 | for _, f := range tt.buildNotExpectedFiles { |
| 787 | if fileExists(f) { |
| 788 | t.Errorf("build not skipped: Expected NOT to find %s", f) |
| 789 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…