Skip to content

Instantly share code, notes, and snippets.

@jonespm
Created September 2, 2015 16:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonespm/e5f176500eee7bf27b22 to your computer and use it in GitHub Desktop.
Save jonespm/e5f176500eee7bf27b22 to your computer and use it in GitHub Desktop.
#!/bin/zsh
# Run a script repeatedly until fail
# Idea from http://stackoverflow.com/questions/12967232/repeatedly-run-a-shell-command-until-it-fails
# If this is in your home dir you can just run it as
# ~/untilfail.sh "some command to run". Running maven tests are good ones
# ~/untilfail.sh "mvn test -Dtest=org.sakaiproject.sitestats.test.StatsUpdateManagerTest"
#shopt -s expand_aliases
#I have important functions and aliases in here
source ${HOME}/.zshrc
COUNT=1
START=`date +%s`
echo "This is run number $COUNT"
$@
while [ $? -eq 0 ]; do
((COUNT++))
echo "This is run number $COUNT"
$@
done
END=`date +%s`
RUNTIME=$((END-START))
echo "Build failed at run number number $COUNT and took $RUNTIME seconds to fail."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment