gotestsum icon indicating copy to clipboard operation
gotestsum copied to clipboard

Support running tests using RR

Open firelizzard18 opened this issue 1 year ago • 3 comments

It would be amazing if gotestsum supported running tests using rr. I've hacked something together to use with --raw-command but it's ugly. I am imagining something like gotestsum --engine rr (with the default being --engine go).

  1. Update gotestsum to process packages separately
    • Detect if the caller passed a specific package, or something ending in /...
    • In the latter case, turn that into a list of packages
    • I used go list -f '{{if .TestGoFiles}}{{.ImportPath}}{{end}}' $1 to list only the packages containing test files
  2. Run the test with rr
    • Add -exec 'rr record -o $TRACE' to the go test invocation
    • This will tell go to execute the test binary using rr
    • The trace location should be derived from the package path
    • Overriding the output location makes it far easier to determine which trace belongs to which package
    • Otherwise the trace for pkg/foo/bar will be written to ~/.local/share/rr/bar.test-0

firelizzard18 avatar Aug 24 '23 22:08 firelizzard18