# Behavior traces — gotestyourself/gotestsum

> Canonical page: https://codevetter.com/unpack/gotestsum/behavior-traces

# Behavior traces — gotestyourself/gotestsum

Scanned commit 3cf14356a16c7931cfeacd7dfee585527618df3d (2026-04-14). Generated by codevetter codevetter 1.15.0 on 2026-10-02.

Source inspection; upstream code and tests were not executed.

Source inspection followed startup and ordinary execution, targeted reruns, report persistence, watch-triggered execution, and both analysis tools. The normal path separates stream scanning from process waiting and final reporting. Reruns preserve historical Execution state while tracking only current retry failures for continuation. Watch mode follows its own execution path and therefore has different option behavior.
- Startup follows main → route → cmd.Run → setupFlags → Parse → setupLogging; version requests return early, watch requests call runWatcher, and other requests call run. — [main.go#L13-L38](https://github.com/gotestyourself/gotestsum/blob/3cf14356a16c7931cfeacd7dfee585527618df3d/main.go#L13-L38) [cmd/main.go#L24-L50](https://github.com/gotestyourself/gotestsum/blob/3cf14356a16c7931cfeacd7dfee585527618df3d/cmd/main.go#L24-L50)
- Ordinary execution follows run → Validate → goTestCmdArgs → startGoTestFn → newEventHandler → ScanTestOutput → Flush → Wait; without arguments it constructs go test -json with ./... unless package selection overrides it. — [cmd/main.go#L279-L315](https://github.com/gotestyourself/gotestsum/blob/3cf14356a16c7931cfeacd7dfee585527618df3d/cmd/main.go#L279-L315) [cmd/main.go#L350-L366](https://github.com/gotestyourself/gotestsum/blob/3cf14356a16c7931cfeacd7dfee585527618df3d/cmd/main.go#L350-L366) [cmd/main.go#L390-L400](https://github.com/gotestyourself/gotestsum/blob/3cf14356a16c7931cfeacd7dfee585527618df3d/cmd/main.go#L390-L400)
- Malformed stdout normally causes readStdout to fail and stopOnError to cancel the child; ignore mode forwards malformed lines to Err, while FAIL-prefixed bad events are handled by a separate continue branch. — [testjson/execution.go#L802-L837](https://github.com/gotestyourself/gotestsum/blob/3cf14356a16c7931cfeacd7dfee585527618df3d/testjson/execution.go#L802-L837) [testjson/execution.go#L894-L907](https://github.com/gotestyourself/gotestsum/blob/3cf14356a16c7931cfeacd7dfee585527618df3d/testjson/execution.go#L894-L907)
- After a failed initial process, run checks hasErrors and the initial failure limit, then rerunFailed filters failures, builds escaped anchored -test.run expressions, starts each retry, scans into shared Execution with a new RunID, and records remaining failures. — [cmd/main.go#L317-L335](https://github.com/gotestyourself/gotestsum/blob/3cf14356a16c7931cfeacd7dfee585527618df3d/cmd/main.go#L317-L335) [cmd/rerunfails.go#L54-L92](https://github.com/gotestyourself/gotestsum/blob/3cf14356a16c7931cfeacd7dfee585527618df3d/cmd/rerunfails.go#L54-L92) [cmd/rerunfails.go#L98-L108](https://github.com/gotestyourself/gotestsum/blob/3cf14356a16c7931cfeacd7dfee585527618df3d/cmd/rerunfails.go#L98-L108) [cmd/rerunfails.go#L128-L156](https://github.com/gotestyourself/gotestsum/blob/3cf14356a16c7931cfeacd7dfee585527618df3d/cmd/rerunfails.go#L128-L156)
- Persistence completes through handler.Flush → finishRun → PrintSummary → writeJUnitFile → junitxml.Write → postRunHook; JUnit or hook errors replace the pending process error, otherwise finishRun returns it. — [cmd/main.go#L304-L315](https://github.com/gotestyourself/gotestsum/blob/3cf14356a16c7931cfeacd7dfee585527618df3d/cmd/main.go#L304-L315) [cmd/main.go#L338-L347](https://github.com/gotestyourself/gotestsum/blob/3cf14356a16c7931cfeacd7dfee585527618df3d/cmd/main.go#L338-L347) [cmd/handler.go#L136-L181](https://github.com/gotestyourself/gotestsum/blob/3cf14356a16c7931cfeacd7dfee585527618df3d/cmd/handler.go#L136-L181) [internal/junitxml/report.go#L95-L100](https://github.com/gotestyourself/gotestsum/blob/3cf14356a16c7931cfeacd7dfee585527618df3d/internal/junitxml/report.go#L95-L100)
- Watch execution follows runWatcher → filewatcher.Watch → loadPaths → handleEvent → runTests → watchRuns.run → runSingle; changed .go paths trigger package runs, and watch-chdir sets the child directory and selector ./. — [cmd/watch.go#L14-L19](https://github.com/gotestyourself/gotestsum/blob/3cf14356a16c7931cfeacd7dfee585527618df3d/cmd/watch.go#L14-L19) [internal/filewatcher/watch.go#L41-L63](https://github.com/gotestyourself/gotestsum/blob/3cf14356a16c7931cfeacd7dfee585527618df3d/internal/filewatcher/watch.go#L41-L63) [internal/filewatcher/watch.go#L244-L276](https://github.com/gotestyourself/gotestsum/blob/3cf14356a16c7931cfeacd7dfee585527618df3d/internal/filewatcher/watch.go#L244-L276) [cmd/watch.go#L45-L95](https://github.com/gotestyourself/gotestsum/blob/3cf14356a16c7931cfeacd7dfee585527618df3d/cmd/watch.go#L45-L95)
- Slow-test analysis follows slowest.Run → run → jsonfileReader → ScanTestOutput → aggregate.Slowest; --skip-stmt adds parseSkipStatement → writeTestSkip → packages.Load → rewriteAST → writeFile instead of printing. — [cmd/tool/slowest/slowest.go#L15-L25](https://github.com/gotestyourself/gotestsum/blob/3cf14356a16c7931cfeacd7dfee585527618df3d/cmd/tool/slowest/slowest.go#L15-L25) [cmd/tool/slowest/slowest.go#L104-L144](https://github.com/gotestyourself/gotestsum/blob/3cf14356a16c7931cfeacd7dfee585527618df3d/cmd/tool/slowest/slowest.go#L104-L144) [cmd/tool/slowest/ast.go#L17-L53](https://github.com/gotestyourself/gotestsum/blob/3cf14356a16c7931cfeacd7dfee585527618df3d/cmd/tool/slowest/ast.go#L17-L53) [cmd/tool/slowest/ast.go#L64-L74](https://github.com/gotestyourself/gotestsum/blob/3cf14356a16c7931cfeacd7dfee585527618df3d/cmd/tool/slowest/ast.go#L64-L74)
- Matrix generation follows matrix.Run → run → readPackages → readTimingReports → packageTiming → packagePercentile → bucketPackages → writeMatrix; fewer than two partitions or an empty timing pattern fails before reading inputs. — [cmd/tool/matrix/matrix.go#L20-L31](https://github.com/gotestyourself/gotestsum/blob/3cf14356a16c7931cfeacd7dfee585527618df3d/cmd/tool/matrix/matrix.go#L20-L31) [cmd/tool/matrix/matrix.go#L80-L109](https://github.com/gotestyourself/gotestsum/blob/3cf14356a16c7931cfeacd7dfee585527618df3d/cmd/tool/matrix/matrix.go#L80-L109)

Every claim links to its cited files at the pinned commit. Citations identify source evidence; they do not establish runtime correctness. Independent CodeVetter scan — not reviewed by upstream maintainers.

## Public product links

- [CodeVetter](https://codevetter.com/)
- [Download](https://codevetter.com/download)
- [Documentation](https://codevetter.com/docs/)
- [Source](https://github.com/Codevetter/codevetter)
