-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtest.sh
executable file
·54 lines (38 loc) · 1.18 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
#!/bin/bash
set -e
VERSIONS=('2.7' '3.4' '3.5' '3.6' '3.7' '3.8')
function runFlake8() {
echo '<--------------------------------------------->'
# run flake8 and exit on error
# it will check the code base against coding style (PEP8) and programming errors
echo "Running flake8..."
flake8 || { echo 'You increased the number of flak8 errors'; exit 1; }
}
function runPyTest() {
echo '<--------------------------------------------->'
python_version=${1}
test_venv="venv_test_${python_version//.}"
echo "Creating virtualenv ${test_venv}..."
virtualenv -p python${python_version} ${test_venv}
echo "Activating virtualenv ${test_venv}..."
if [ -f ${test_venv}/bin/activate ]; then
source ${test_venv}/bin/activate
fi
if [ -f ${test_venv}/Scripts/activate ]; then
source ${test_venv}/Scripts/activate
fi
echo 'Installing dependencies...'
pip install -r requirements.txt
runFlake8
echo 'Running pytest...'
py.test
echo "Deactivating virtualenv..."
deactivate
}
echo 'Removing all existing virtualenv'
rm -rf venv_test_* | true
for i in "${VERSIONS[@]}"
do
runPyTest ${i}
done
echo 'Done'