-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.sh
executable file
·79 lines (66 loc) · 1.37 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
#!/bin/bash
if [ "$EUID" -ne 0 ]; then
cat 1>&2 <<-EOM
The test script needs to be run with superuser privileges. It needs to start a
series of Docker containers.
EOM
exit 1
fi
set -euo pipefail
run() {
(
source pyenv/bin/activate
PYTHONPATH=$(pwd):$(pwd)/tests:${PYTHONPATH:-} \
pytest --color=yes $@ \
| tee pytest.log
)
}
build() {
(
cd tests/database
sudo -u ${SUDO_USER:-root} make Dockerfile
docker build -t damast-pytest-testdb .
)
if [ ! -d pyenv ]
then
python3 -m venv pyenv
(
source pyenv/bin/activate
pip install --upgrade pip
pip install wheel
pip install 'flask==2.3.2' 'gunicorn[gevent]' 'requests' 'Flask-HTTPAuth' \
'passlib[bcrypt]' 'pyjwt>=2' 'pyyaml' 'postgres' 'password-strength' \
'brotli' 'apscheduler' 'html5lib' 'jsonschema==3.2.0' 'python-dateutil' \
'beautifulsoup4' 'python-Levenshtein==0.12.2' 'wheel' 'pytest' \
'pytest-xdist' 'pytest-timeout'
)
fi
}
about() {
cat 1>&2 <<EOF
Usage: test.sh [-h] [-b]
Run pytest tests.
-h Show this help and exit.
-b Instead of testing, build the necessary Docker image and create the
virtualenv.
EOF
}
OPTIND=0
while getopts hb opt
do
case $opt in
h)
about
exit 0
;;
b)
build
exit 0
;;
*)
about
exit 1
;;
esac
done
run $@