-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathruntest.sh
More file actions
executable file
·79 lines (74 loc) · 2.13 KB
/
runtest.sh
File metadata and controls
executable file
·79 lines (74 loc) · 2.13 KB
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
#! /bin/bash
SECONDS=0
unittest=false
flake8=false
testcase=false
clean=false
docker=false
if [ $# -eq 0 ]; then
flake8=true
unittest=true
else
for argval in "$@"
do
if [ "$argval" == "clean" ]; then
flake8=true
clean=true
fi
if [ "$argval" == "flake8" ]; then
flake8=true
fi
if [ "$argval" == "unit" ] || [ "$argval" == "unittest" ]; then
unittest=true
fi
if [ "$argval" == "all" ]; then
unittest=true
flake8=true
fi
if [ "$argval" == "case" ]; then
testcase=true
fi
if [ "$testcase" = true ] && [[ "$argval" =~ ^tests.* ]]; then
label=$argval
fi
done
fi
if [ "$flake8" = true ]; then
echo "# checking flake8..."
if flake8 --jobs=auto; then
echo -e "OK\n"
else
exit
fi
fi
if [ "$docker" = true ]; then
if ! docker-compose --dry-run up -d --build; then
exit
fi
fi
if [ "$clean" = true ]; then
echo "# running unittests with clean db..."
python -Wa manage.py test --noinput --parallel --settings=tests.test_settings
fi
if [ "$unittest" = true ]; then
echo "# running unittests..."
python -Wa manage.py test --keepdb --parallel --settings=tests.test_settings
fi
if [ "$testcase" = true ]; then
echo "# running specific case $label..."
python -Wa manage.py test --keepdb --settings=tests.test_settings $label --debug-mode
fi
if [ "$clean" = false ] && [ "$flake8" = false ] && [ "$unittest" = false ] && [ "$testcase" = false ]; then
echo "Usage: ./runtest.sh [options] ..."
echo "* run all tests if no options provided"
echo -e "\nOptions:"
echo -e "flake8\t\t\t run flake8 only"
echo -e "unit, unittest\t\t run unit test only"
echo -e "case [case name]\t run a specific unit test in debug-mode"
echo -e " - example of case name\t [tests.accounts.test_login.LoginTest]"
echo -e "all\t\t\t run both flake8 and unit test"
echo -e "clean\t\t\t run unit test without --keepdb option"
else
duration=$SECONDS
echo "# test finished in $duration seconds."
fi