run_tests.sh should exit non-zero when tests fail

If any test fail set set a global flag to a non-zero value.  Exit
with that value.
This commit is contained in:
Jay Buffington 2012-12-12 10:28:02 -08:00
parent 13be0e65e3
commit 9406fc5d64

View File

@ -5,6 +5,9 @@ set -u
NOSEARGS= NOSEARGS=
JUST_PEP8=0 JUST_PEP8=0
# this flag will get set to 1 if any tests fail
FAILED_TESTS=0
function usage { function usage {
echo "Usage: $0 [OPTION]..." echo "Usage: $0 [OPTION]..."
echo "Run anvils test suite." echo "Run anvils test suite."
@ -42,6 +45,7 @@ function run_pep8 {
if [ "$?" -ne "0" ]; then if [ "$?" -ne "0" ]; then
echo "Some badness was found!" echo "Some badness was found!"
echo "Check '$output_filename' for a full report." echo "Check '$output_filename' for a full report."
FAILED_TESTS=1
else else
echo "You are a pep8 guru!" echo "You are a pep8 guru!"
fi fi
@ -67,6 +71,7 @@ function run_pylint {
if [ "$?" -eq "0" ]; then if [ "$?" -eq "0" ]; then
echo "Your code is perfect you code master!" echo "Your code is perfect you code master!"
else else
FAILED_TESTS=1
echo "You are not yet a code master." echo "You are not yet a code master."
grep -i "Your code" $output_filename grep -i "Your code" $output_filename
echo "Check '$output_filename' for a full report." echo "Check '$output_filename' for a full report."
@ -79,6 +84,9 @@ function run_tests {
# Cleanup *.pyc # Cleanup *.pyc
find . -type f -name "*.pyc" -delete find . -type f -name "*.pyc" -delete
$NOSETESTS $NOSETESTS
if [ "$?" -ne "0" ]; then
FAILED_TESTS=1
fi
} }
function validate_yaml { function validate_yaml {
@ -88,6 +96,7 @@ function validate_yaml {
python tools/validate-yaml.py $f python tools/validate-yaml.py $f
if [ "$?" -ne "0" ]; then if [ "$?" -ne "0" ]; then
echo "File: $f has some badness in it!" echo "File: $f has some badness in it!"
FAILED_TESTS=1
fi fi
done done
} }
@ -100,10 +109,13 @@ export NOSETESTS="nosetests $NOSEARGS"
if [ $JUST_PEP8 -eq 1 ]; then if [ $JUST_PEP8 -eq 1 ]; then
run_pep8 run_pep8
exit 0 exit $FAILED_TESTS
fi fi
run_tests run_tests
run_pep8 run_pep8
run_pylint run_pylint
validate_yaml validate_yaml
exit $FAILED_TESTS