Skip to content

A more minimal approach to retrying failed examples

gitlab-qa-bot requested to merge github/fork/antifun/official-retry into master

Created by: antifun

So after the discussion on #456 (closed), here's a crack at a less-invasive way to do the retry.

Given a formatter that outputs the names of failed examples only like so:

-e 'Example name that failed'
-e 'Another example name that failed'

You can get that output into a file using an rspec invocation like so:

rspec specs/*.spec --format f -o failures.txt ...

And then upon determining that some examples have failed, rerun just those examples like so:

rspec specs/*.spec -O failures.txt ...

In order to make this possible I had to make two changes to rspec itself, not counting the formatter: -e is now additive, and options provided in the -O file (and in .rspec, etc.) are now split using shell semantics rather than on whitespace (which I would have considered a bug).

Let me know what you think. The formatter is perhaps controversial if only because it's so trivial. I favor just going ahead and making it work out of the box, but I could also be convinced of alternatives like splitting it out into a separate distribution or having it not output the "-e" hiccup and leaving the prepending of "-e" to each line in this usage to the enterprising rspec user.

Merge request reports