Skip to content

Instantly share code, notes, and snippets.

Created December 27, 2012 09:30
Show Gist options
  • Save anonymous/4386894 to your computer and use it in GitHub Desktop.
Save anonymous/4386894 to your computer and use it in GitHub Desktop.
#! /bin/bash
SHOW_COVERAGE=0
if [ "$1" == "-" ]
then
SHOW_COVERAGE=1
app=""
else
app=$1
fi
if [ "$2" == "-" ]
then
SHOW_COVERAGE=1
fi
# Get package name
array_split=(${app//./ })
cover_package=${array_split[0]}
cmd_line="--with-coverage --cover-html"
if [ "$cover_package" != "" ]
then
cmd_line="$cmd_line --cover-package=$cover_package"
fi
# Run tests
./manage.py test $app $cmd_line
RETVAL=$?
if [ $RETVAL -eq 0 ]
then
notify-send --urgency=critical --icon=info "All tests are passed"
else
notify-send --urgency=critical --icon=error "Some tests are failed"
fi
if [ $SHOW_COVERAGE -eq 1 ]
then
nohup gnome-open ./cover/index.html &> /dev/null
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment