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 $PATH
in your terminal.) - Download the
until-fail
file from the gist. (Click the "Raw" button on theuntil-fail
file. - Create a
until-fail
file in the open directory and paste in theuntil-fail
file contents. - Make the file executable with
chmod +x until-fail
. - Now call the excutable with a command.