-
Notifications
You must be signed in to change notification settings - Fork 1
/
runtests.sh
executable file
·64 lines (54 loc) · 1.22 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
58
59
60
61
62
63
64
#! /bin/bash
# Runs unit tests optionally with coverage and reporting or HTML output.
do_coverage=false
do_report=false
do_html=false
# get the directory the script lives in and cd to it, might want this variable for later additions
homedir="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$homedir"
# parse arguments
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
--coverage)
do_coverage=true
;;
--report)
do_report=true
;;
--html)
do_html=true
;;
--help)
echo "runtests.sh [--coverage] [--report] [--html] [--help] FILES*"
exit 0
;;
*)
# don't eat any file names passed on the command line
break
;;
esac
shift
done
# run tests and other coverage operations if requested
if [ $do_coverage = true ]
then
rm -f .coverage coverage.xml
coverage run --omit=tests/*.py --branch -m unittest -c $*
result=$?
coverage xml
if [ $do_report = true ]
then
coverage report
fi
if [ $do_html = true ]
then
rm -rf htmlcov
coverage html
fi
else
python -m unittest -c $*
result=$?
fi
exit $result