@@ -174,3 +174,51 @@ func TestScanTestOutput_TestTimeoutPanicRace(t *testing.T) {
174
174
})
175
175
}
176
176
}
177
+
178
+ // Tests output when a package fails to build because of a compilation error
179
+ // and no tests are run in the package.
180
+ func TestEventHandler_TestBuildFail (t * testing.T ) {
181
+ t .Setenv ("GITHUB_ACTIONS" , "no" )
182
+
183
+ buf := new (bufferCloser )
184
+ errBuf := new (bytes.Buffer )
185
+ format := testjson .NewEventFormatter (errBuf , "testname" , testjson.FormatOptions {})
186
+
187
+ source := golden .Get (t , "input/go-test-build-failed.out" )
188
+ cfg := testjson.ScanConfig {
189
+ Stdout : bytes .NewReader (source ),
190
+ Handler : & eventHandler {jsonFile : buf , formatter : format },
191
+ }
192
+ exec , err := testjson .ScanTestOutput (cfg )
193
+ assert .NilError (t , err )
194
+
195
+ out := new (bytes.Buffer )
196
+ testjson .PrintSummary (out , exec , testjson .SummarizeAll )
197
+
198
+ actual := text .ProcessLines (t , out , text .OpRemoveSummaryLineElapsedTime )
199
+ golden .Assert (t , actual , "expected/build-fail-expected" )
200
+ }
201
+
202
+ // Tests output when a package fails to build because of a compilation error
203
+ // due to syntax errors and the like.
204
+ func TestEventHandler_SetupFail (t * testing.T ) {
205
+ t .Setenv ("GITHUB_ACTIONS" , "no" )
206
+
207
+ buf := new (bufferCloser )
208
+ errBuf := new (bytes.Buffer )
209
+ format := testjson .NewEventFormatter (errBuf , "testname" , testjson.FormatOptions {})
210
+
211
+ source := golden .Get (t , "input/go-test-setup-failed.out" )
212
+ cfg := testjson.ScanConfig {
213
+ Stdout : bytes .NewReader (source ),
214
+ Handler : & eventHandler {jsonFile : buf , formatter : format },
215
+ }
216
+ exec , err := testjson .ScanTestOutput (cfg )
217
+ assert .NilError (t , err )
218
+
219
+ out := new (bytes.Buffer )
220
+ testjson .PrintSummary (out , exec , testjson .SummarizeAll )
221
+
222
+ actual := text .ProcessLines (t , out , text .OpRemoveSummaryLineElapsedTime )
223
+ golden .Assert (t , actual , "expected/setup-fail-expected" )
224
+ }
0 commit comments