-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Milestone
Description
I propose we add a testing flag to cause go test to exit after the first test failure.
There are two cases where I've wanted such a flag:
- When I'm debugging a flaky test, I want to run it until failure. I often use
-count 10000for this purpose, but it will keep running the test after it fails once, so if I'm not looking at my terminal while it's running I need to go hunt through my scrollback to locate the failure. (Alternatively, I can usego test -cand re-run the test until failure using my shell, but this is slower, particularly if there's some kind of setup in a TestMain.) - When I'm debugging a test that has many failures, I want to focus on and fix a single test at a time. Today I can pick one of the failures and use
-runto select it, but then once I've fixed that failure I want to focus the next one so I need to run all the tests again and repeat the process. It would be more convenient to rungo test -exit1(need a better flag name).
In the presence of t.Parallel this gets a little trickier. I suggest handling it by collecting the parallel results as they arrive and then exiting after the first failure, printing only the results that came in before the failure and then the failure last, but not printing results that arrived after the failure. The main subtlety for the user is that they might see output logged from other parallel tests which don't have success/failure printouts, but that seems like a minor concern.
Reactions are currently unavailable