Skip to content

Instantly share code, notes, and snippets.

@Stubbs
Created January 17, 2012 10:30
Show Gist options
  • Save Stubbs/1626139 to your computer and use it in GitHub Desktop.
Save Stubbs/1626139 to your computer and use it in GitHub Desktop.
pre-commit hook to stop you commiting broken tests.
#!/bin/sh
# Script to check the status of the last test run & cancel the commit if there are any errors or failures
RESULTS="tests/reports/testsuites.xml"
# Check the test results exist, and have results in them.
if [ ! -s $RESULTS ]
then
echo "WTF is this shit? You've not even tried to run the tests. You suck, man."
exit 1
fi
if grep 'errors="[1-9]\+"' $RESULTS
then
echo "There are unit test errors, ALL ERRORS MUST DIE!!"
exit 1
fi
if grep 'failues="[1-9]\+"' $RESULTS
then
echo "There are test failures ... you've not just let yourself down, but you've let me down too."
exit 1
fi
@willmacdonald
Copy link

L20: 'failues' ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment