-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathrun-tests.sh
executable file
·83 lines (69 loc) · 1.11 KB
/
run-tests.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env bash
# Runs the unit tests.
VENV='.venv'
function banner {
echo ''
echo '********************'
echo "$*"
echo '********************'
echo ''
}
usage="run-tests.sh [travis]"
update_venv=true
case "$#" in
0)
;;
1)
if [ "$1" != "travis" ]
then
echo $usage >&2
exit 1
fi
update_venv=false
;;
*)
echo $usage >&2
exit 1
;;
esac
packages="bdc gendbc db_edu_util course master_parse"
test_dirs=
for p in $packages
do
if [ -d $p/tests ]
then
test_dirs="$test_dirs $p/tests"
fi
done
if [ "$update_venv" = "true" ]
then
if [ ! -d $VENV ]
then
banner "Creating virtual environment in $VENV"
virtualenv $VENV
fi
. $VENV/bin/activate
echo Using $(type -p python)
banner "Reinstalling build tools and test harness"
python setup.py install
pip install pytest
fi
failed=false
here=`pwd`
for d in $test_dirs
do
cd $d || exit 1
banner "Running tests in $d"
pytest -W ignore -ra --cache-clear .
if [ $? -ne 0 ]
then
failed=true
fi
cd $here
done
if [ $failed = true ]
then
banner "Tests failed."
exit 1
fi
exit 0