Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rerun failed tests #126

Merged
merged 6 commits into from
Jun 11, 2020
Merged

Rerun failed tests #126

merged 6 commits into from
Jun 11, 2020

Conversation

dnephin
Copy link
Member

@dnephin dnephin commented Jun 6, 2020

Adds a new --rerun-fails[=n] flag. When the flag is used gotestsum will rerun any failed tests up to n times until each one passes at least once.

The new feature can be used to mitigate the pain of flaky tests in CI. To avoid unnecessarily rerunning tests when there is a bug or problem with the test environment, if there are more than 10 failed tests, rerun will be skipped. The --rerun-fails-max-failures flag can be used to change that threshold.

Using the --rerun-fails flag along with --raw-command or with go test args may require special handling, which will need to be documented in #117

@dnephin dnephin force-pushed the rerun-fails branch 6 times, most recently from 6b4f95b to 16e5df2 Compare June 7, 2020 22:00
@dnephin dnephin marked this pull request as ready for review June 7, 2020 22:00
@dnephin dnephin force-pushed the rerun-fails branch 4 times, most recently from 695fc6d to 0c589cf Compare June 8, 2020 03:04
rerunfails.go Outdated Show resolved Hide resolved
This fixes a bug, and prevents one in the new rerun-fails feature.

Incomplete tests were printed in the summary, but never passed to the EventHandler. Now when the execution ends, fake TestEVent will be created and sent to the Handler, so that it can print the output of the failed test.

This allows the rerun-fails loop to include these failed tests in the count, and avoid a situation where a test was panicing, but not getting rerun. If the panic test did not get rerun then 'go test' may exit 0, making it look like everything had passed, when in fact one test was still panicing.

This type of bug sounds pretty severe.
Also print help text to stdout when it is requested with --help.
Continue to print to stderr when it is a result of an invalid flag.

Also add missing command help to root command.
Rename the rerun-fails flag, and improve the help text. Also add a test for options.Validate
Use -count=1 because there appears to be a bug in the 'go test' cache
that has it PASS (cached) instead of failing when SEED=3.
@dnephin dnephin merged commit dcc31b5 into gotestyourself:master Jun 11, 2020
@dnephin dnephin deleted the rerun-fails branch June 11, 2020 01:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant