Skip to content
Newer
Older
100644 100 lines (81 sloc) 2.5 KB
b1f76a1 @fivethreeo initial commit
authored Sep 13, 2011
1 #!/bin/bash
2
3 find . -name '*.pyc' -delete
4
5 args=("$@")
6 num_args=${#args[@]}
7 index=0
8
9 django=12
10 reuse_env=true
11 disable_coverage=true
12 update_requirements=false
13
14 python="python" # to ensure this script works if no python option is specified
15 while [ "$index" -lt "$num_args" ]
16 do
17 case "${args[$index]}" in
18 "-f"|"--failfast")
19 failfast="--failfast"
20 ;;
21
22 "-r"|"--rebuild-env")
23 reuse_env=false
24 ;;
25
26 "-u"|"--update-requirements")
27 update_requirements=true
28 ;;
29
30 "-d"|"--django")
31 let "index = $index + 1"
32 django="${args[$index]}"
33 ;;
34
35 "-p"|"--python")
36 let "index = $index + 1"
37 python="${args[$index]}"
38 ;;
39
40 "-c"|"--with-coverage")
41 disable_coverage=false
42 ;;
43
44 "-h"|"--help")
45 echo ""
46 echo "usage:"
47 echo " runtests.sh"
48 echo ""
49 echo "flags:"
50 echo " -r, --rebuild-env - delete virtualenv and rebuild virtualenv before the tests"
51 echo " -u, --update-requirements - update requirements before the tests"
52 echo " -d, --django <version> - run tests against a django version, options: 12, 13 or trunk"
53 echo " -c, --with-coverage - enables coverage"
54 echo " -p, --python /path/to/python - python version to use to run the tests"
55 echo " -h, --help - display this help"
56 exit 1
57 ;;
58 esac
59 let "index = $index + 1"
60 done
61
62 python_executeable=`which $python`
63
64 echo "using python at: $python_executeable"
65
66 venv="venv-$python-$django"
67
68 if [ $reuse_env == false ]; then
69 rm -rf $venv
70 echo "deleted virtualenv: $venv"
71 fi
72
73 if [ ! -d $venv ]; then
74 echo "building virtualenv"
75 virtualenv $venv --distribute -p $python_executeable
76 update_requirements=true
77 else
78 echo "reusing current virualenv: $venv"
79 fi
80
81 if [ $update_requirements == true ]; then
82 echo "updating requirements"
83 $venv/bin/pip install -r requirements-$django.txt
84 $venv/bin/pip install -r requirements.txt
85 fi
86
87 if [ $disable_coverage == false ]; then
88 $venv/bin/coverage run --rcfile=coveragerc setup.py test
89 retcode=$?
90 echo "build coverage reports"
91
92 $venv/bin/coverage xml --rcfile=coveragerc
93 $venv/bin/coverage html --rcfile=coveragerc
94 $venv/bin/coverage report -m --rcfile=coveragerc
95 else
96 $venv/bin/python setup.py test
97 retcode=$?
98 fi
99 exit $retcode
Something went wrong with that request. Please try again.