forked from uber-archive/pyflame
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathruntests.sh
More file actions
executable file
·49 lines (41 loc) · 1.02 KB
/
runtests.sh
File metadata and controls
executable file
·49 lines (41 loc) · 1.02 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
#!/bin/bash
set -ex
ENVDIR="./test_env"
# Run tests using pip; $1 = python version
run_pip_tests() {
virtualenv -p "$1" "${ENVDIR}"
trap "rm -rf ${ENVDIR}" EXIT
. "${ENVDIR}/bin/activate"
pip install --upgrade pip
pip install pytest
py.test tests/
# clean up the trap
rm -rf "${ENVDIR}" EXIT
trap "" EXIT
}
# See if we can run the pip tests with this Python version
try_pip_tests() {
if which "$1" &>/dev/null; then
run_pip_tests "$1"
fi
}
# This runs the tests for building an RPM
run_fedora_tests() {
py.test-2 tests/
py.test-3 tests/
}
if [ "$1" = "fedora" ]; then
# If the first arg is fedora, don't use Pip
run_fedora_tests
elif [ $# -eq 1 ]; then
# Run the tests for a particular version of python
run_pip_tests "$1"
elif [ -n "$PYTHONVERSION" ]; then
# Run the tests for $PYTHONVERSION
run_pip_tests "$PYTHONVERSION"
else
# Try various places where we might find Python
for py in python{,2,3}; do
try_pip_tests "$py"
done
fi