@@ -72,6 +72,40 @@ func runTest(t *testing.T, test *linterTest, changedGoldensList *ChangedGoldensL
7272 }
7373}
7474
75+ func runTests (t * testing.T , tests []* linterTest ) {
76+ read := func (file string ) []byte {
77+ bytz , err := ioutil .ReadFile (file )
78+ if err != nil {
79+ t .Fatalf ("reading file: %s: %v" , file , err )
80+ }
81+ return bytz
82+ }
83+
84+ vm := jsonnet .MakeVM ()
85+
86+ var snippets []Snippet
87+
88+ for _ , test := range tests {
89+ input := read (test .input )
90+
91+ snippets = append (snippets , Snippet {FileName : test .name , Code : string (input )})
92+ }
93+
94+ var outBuilder strings.Builder
95+
96+ errorsFound := LintSnippet (vm , & outBuilder , snippets )
97+
98+ outData := outBuilder .String ()
99+
100+ if outData == "" && errorsFound {
101+ t .Error (fmt .Errorf ("return value indicates problems present, but no output was produced" ))
102+ }
103+
104+ if outData != "" && ! errorsFound {
105+ t .Error (fmt .Errorf ("return value indicates no problems, but output is not empty:\n %v" , outData ))
106+ }
107+ }
108+
75109func TestLinter (t * testing.T ) {
76110 flag .Parse ()
77111
@@ -122,4 +156,8 @@ func TestLinter(t *testing.T) {
122156 t .Fail ()
123157 })
124158 }
159+
160+ t .Run ("passing multiple input files" , func (t * testing.T ) {
161+ runTests (t , tests )
162+ })
125163}
0 commit comments