-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathruntests.sh
executable file
·57 lines (45 loc) · 1.01 KB
/
runtests.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
set -e # Abort on first error
function usage()
{
cat <<-ENDOFMESSAGE
$0 [OPTIONS]
options:
-c With coverage.
-p Path to tests. Accepts specific test/test suite.
-h Display this message.
-m Run migrations before pytest. Needed for first time
after cloning or after modifying the DB schema.
ENDOFMESSAGE
exit 1
}
if [ -z "$VIRTUAL_ENV" ]; then
echo "Make sure you run the tests in a virtualenv!!"
exit 1
fi
COVERAGE=""
TEST_PATH=rafee
export DJANGO_SETTINGS_MODULE=rafee.settings.test
while getopts "hp:cm" opt; do
case $opt in
c)
echo "Running tests with coverage!" >&2
COVERAGE="--cov rafee --cov-report html --cov-report xml"
;;
m)
echo "Running migrations!" >&2
find . -name "*.pyc" -exec rm -rf {} \;
python manage.py makemigrations && python manage.py migrate
;;
p)
TEST_PATH=$OPTARG
;;
h)
usage
;;
\?)
usage
;;
esac
done
py.test -q --durations=3 $COVERAGE $TEST_PATH