Last active
August 29, 2015 14:04
-
-
Save clemsos/ee3dbd2ee7434e057673 to your computer and use it in GitHub Desktop.
Bash script to run test with colored output using Python nosetest (all files or a single file)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# USAGE : | |
# | |
# chmod +x run_tests.sh | |
# ./run_tests.sh # run all tests | |
# ./run_tests.sh xxx.py # run a single test | |
# | |
test_dir=`pwd`/tests | |
testfile=$1 | |
run_all () { | |
echo >&2 "$@" | |
for entry in "$test_dir"/* | |
do | |
if [ -f "$entry" ]; | |
then | |
file="${entry##*/}" | |
if [[ "$file" == test_* ]] && [[ "$file" != *pyc ]] | |
then | |
nosetests --rednose --force-color ${entry} | |
fi | |
fi | |
done | |
exit 1 | |
} | |
run_one () { | |
# test extension | |
if test ${testfile##*.} != "py"; then die "Invalid file extension. File should be *.py"; fi | |
# launch script | |
nosetests --rednose --force-color $test_dir/${testfile##*/} | |
} | |
die () { | |
echo >&2 "$@" | |
exit 1 | |
} | |
[ "$#" -eq 1 ] || run_all | |
run_one |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment