-
Notifications
You must be signed in to change notification settings - Fork 5
/
test.sh
executable file
·85 lines (75 loc) · 1.56 KB
/
test.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
84
85
#!/bin/bash
set -e
usage() {
echo "* Usage: $0 [app_or_apps_to_test][--fast][--with-migrations][--skip-linter][--skip-coverage]" >&2
exit 1
}
LINTER=true
COVERAGE=true
SETUP=true
POSITIONAL=()
# Parse arguments.
for PARAM in "$@"; do
case $PARAM in
--fast)
LINTER=false
COVERAGE=false
SETUP=false
;;
--with-migrations)
export TEST_MIGRATIONS=true
;;
--skip-linter)
LINTER=false
;;
--skip-coverage)
COVERAGE=false
;;
--skip-setup)
SETUP=false
;;
--help)
usage
;;
*)
POSITIONAL+=("$PARAM")
;;
esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters
if $SETUP; then
echo "=== setup docker ==="
PYTHONPATH="$PWD:$PYTHONPATH" python tools/setup_codebox.py
fi
if $LINTER; then
make lint
fi
CMD="manage.py test --noinput --parallel ${PARALLEL_COUNT:-2} $*"
if [ "${LEGACY_CODEBOX_ENABLED:-false}" != "true" ]; then
CMD="${CMD} --exclude-tag legacy_codebox"
fi
if [ "$#" == 0 ]; then
CMDS=("${CMD} -e response_templates" "${CMD} response_templates")
else
CMDS=("${CMD}")
fi
# Run tests
export DJANGO_SETTINGS_MODULE=settings.tests
if $COVERAGE; then
coverage erase
for cmd in "${CMDS[@]}"; do
# shellcheck disable=SC2086
coverage run $cmd
done
coverage combine
else
for cmd in "${CMDS[@]}"; do
# shellcheck disable=SC2086
python $cmd
done
fi
if $COVERAGE; then
echo
echo "=== coverage report ==="
coverage report
fi