Retry a command until it fails.
Debugging brittle specs is annoying and time consuming work. Let's automate finding those brittle specs by retrying them until they fail.
Accompanying blog post.
$ until-fail true
# Will repeat forever
$ until-fail false
# Fails at the first iteration and break out of the retry loop
$ until-fail ruby -e "(rand(0..1) == 1) ? (puts 'failed'; exit(1)) : (puts 'success')"
# Fails randomly and breaks out of the retry loop when it fails
- Open a directory that's in your local
$PATH. (See the list withecho $PATHin your terminal.) - Download the
until-failfile from the gist. (Click the "Raw" button on theuntil-failfile. - Create a
until-failfile in the open directory and paste in theuntil-failfile contents. - Make the file executable with
chmod +x until-fail. - Now call the excutable with a command.