1

I have a Go project that uses modules. The module contains many packages, which are nested.

When I let Go figure out the package structure by passing ./... to go test it runs the tests in parallel (the default behaviour).

Testing a single package with the -failfast flag works, it stops at the first failure, however what I'd like to achieve is to use -failfast across all the packages combined (for increased CI/CD throughput). When the first test in one of the packages that are tested in parallel by a single go test ./... invocation fails, I'd like to stop the whole test suite.

Is this even possible with the current version of the go testing utility? If not, is there perhaps a plan to implement such thing in the future?

I did not find a solution that would enable me to do this in parallel yet, however one thing that I thought of is to combine something like go test -failfast, go list ./... and xargs and run tests in a sequence (not parallely). I'd check the output of the last tested package and stop everything on first failure. This doesn't sound that good though and will probably be quite a bit slower.

So yeah, are there any existing solutions or approaches that I haven't found/thought of?

Thanks!

go version go1.12 darwin/amd64

Rok
  • 787
  • 9
  • 17
  • 1
    I don't believe it's currently possible. For what's planned for the future, see the Go issue tracker in Github and the Go mailing lists. I wouldn't expect it any time soon though; one of the major goals of Go is to have the build/test cycle as fast as possible, and typically there's a lot more value from knowing about everything that failed than just the first thing that failed, so I doubt this is a high-demand feature. – Adrian May 24 '19 at 14:09
  • 1
    Relevant discussion is here: https://github.com/golang/go/issues/33038 – Onlyjob Oct 21 '19 at 12:08

0 Answers0