CodeVetter · Repo Unpack · Data flow
gotestyourself/gotestsum
Arguments and environment defaults determine the executable, package selectors, formatter, and report destinations. Subprocess stdout supplies JSON events while stderr supplies displayed diagnostics and selected execution errors. Execution accumulates test state before handlers render or persist events. Reports and analysis tools reuse this event model, but raw JSON persistence and synthesized state have different contents.
- setupFlags disables interspersed parsing; cmd.Run stores remaining arguments for the child, and package selection prioritizes rerun package, --packages, TEST_DIRECTORY, then a supplied default.
- startGoTest connects inherited stdin, captures stdout/stderr pipes, applies an optional child working directory, and starts the executable using exec.CommandContext.
- ScanTestOutput reads stdout and stderr in two errgroup goroutines; readStdout attaches RunID and updates Execution before invoking Handler.Event.
- Execution routes build-output into errors, package events into Package.addEvent, and named test events into Package.addTestEvent; test instances receive package-local IDs, RunID, timestamps, and attributes.
- Output is indexed by test ID with package output at ID 0; successful root tests release output, while subtest and skipped-output retention supports attribution workarounds.
- Err receives stderr before filtering; module-download messages, GODEBUG cache messages, and warning-prefixed lines are excluded from Execution.Errors, while other lines are retained.
- eventHandler writes original JSON bytes before formatting, excludes artificial events with empty bytes, syncs logs before finishRun, and supplies report paths plus execution counts to postRunHook.
- ci-matrix scans each matched report into package elapsed times, selects the nearest-rank 85th percentile, greedily assigns packages to the least-loaded bucket, and serializes include entries with estimatedRuntime and package strings.