forked from fabric8-analytics/graph-cve-sync
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runtests.sh
executable file
·37 lines (27 loc) · 1007 Bytes
/
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
#!/bin/bash
set -e
set -x
COVERAGE_THRESHOLD=80
echo "Create Virtualenv for Python deps ..."
function prepare_venv() {
VIRTUALENV=$(which virtualenv)
if [ $? -eq 1 ]
then
# python34 which is in CentOS does not have virtualenv binary
VIRTUALENV=$(which virtualenv-3)
fi
${VIRTUALENV} -p python3 venv && source venv/bin/activate
if [ $? -ne 0 ]
then
printf "%sPython virtual environment can't be initialized%s" "${RED}" "${NORMAL}"
exit 1
fi
pip3 install -U pip
python3 "$(which pip3)" install -r requirements.txt --upgrade
python3 "$(which pip3)" install -r tests/requirements.txt
}
[ "$NOVENV" == "1" ] || prepare_venv || exit 1
$(which pip3) install pytest
$(which pip3) install pytest-cov
PYTHONDONTWRITEBYTECODE=1 PYTHONPATH=$(pwd) python3 "$(which pytest)" --cov=. --cov-config .coveragerc --cov-report term-missing --cov-fail-under=$COVERAGE_THRESHOLD -vv tests/
printf "%stests passed%s\n\n" "${GREEN}" "${NORMAL}"