Skip to content

Commit 1c9f356

Browse files
pohlyonsi
authored andcommitted
ginkgo: report exit result in case of failure
When a worker unexpectedly dies, it's hard to determine why. Even if output is available (--output-interceptor-mode=none), if it gets killed by the Linux OOM killer there's nothing in the process output about that. Including a textual description of the exit status provides that information (here simulated with `killall -KILL e2e.test`): Output from proc 1: I1204 10:03:40.282670 196272 e2e.go:109] Starting e2e run "82689063-1787-40c3-be7d-c4677c556063" on Ginkgo node 1 Exit result of proc 1: signal: killed
1 parent ece19c8 commit 1c9f356

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

ginkgo/internal/run.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,15 @@ func runSerial(suite TestSuite, ginkgoConfig types.SuiteConfig, reporterConfig t
160160

161161
func runParallel(suite TestSuite, ginkgoConfig types.SuiteConfig, reporterConfig types.ReporterConfig, cliConfig types.CLIConfig, goFlagsConfig types.GoFlagsConfig, additionalArgs []string) TestSuite {
162162
type procResult struct {
163+
proc int
164+
exitResult string
163165
passed bool
164166
hasProgrammaticFocus bool
165167
}
166168

167169
numProcs := cliConfig.ComputedProcs()
168170
procOutput := make([]*bytes.Buffer, numProcs)
171+
procExitResult := make([]string, numProcs)
169172
coverProfiles := []string{}
170173

171174
blockProfiles := []string{}
@@ -233,6 +236,8 @@ func runParallel(suite TestSuite, ginkgoConfig types.SuiteConfig, reporterConfig
233236
cmd.Wait()
234237
exitStatus := cmd.ProcessState.Sys().(syscall.WaitStatus).ExitStatus()
235238
procResults <- procResult{
239+
proc: proc,
240+
exitResult: cmd.ProcessState.String(),
236241
passed: (exitStatus == 0) || (exitStatus == types.GINKGO_FOCUS_EXIT_CODE),
237242
hasProgrammaticFocus: exitStatus == types.GINKGO_FOCUS_EXIT_CODE,
238243
}
@@ -245,6 +250,7 @@ func runParallel(suite TestSuite, ginkgoConfig types.SuiteConfig, reporterConfig
245250
result := <-procResults
246251
passed = passed && result.passed
247252
suite.HasProgrammaticFocus = suite.HasProgrammaticFocus || result.hasProgrammaticFocus
253+
procExitResult[result.proc-1] = result.exitResult
248254
}
249255
if passed {
250256
suite.State = TestSuiteStatePassed
@@ -264,6 +270,8 @@ func runParallel(suite TestSuite, ginkgoConfig types.SuiteConfig, reporterConfig
264270
for proc := 1; proc <= cliConfig.ComputedProcs(); proc++ {
265271
fmt.Fprintf(formatter.ColorableStdErr, formatter.F("{{bold}}Output from proc %d:{{/}}\n", proc))
266272
fmt.Fprintln(os.Stderr, formatter.Fi(1, "%s", procOutput[proc-1].String()))
273+
fmt.Fprintf(formatter.ColorableStdErr, formatter.F("{{bold}}Exit result of proc %d:{{/}}\n", proc))
274+
fmt.Fprintln(os.Stderr, formatter.Fi(1, "%s\n", procExitResult[proc-1]))
267275
}
268276
fmt.Fprintf(os.Stderr, "** End **")
269277
}

0 commit comments

Comments
 (0)