-
Notifications
You must be signed in to change notification settings - Fork 0
/
test
executable file
·65 lines (52 loc) · 1.23 KB
/
test
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
#!/bin/bash -e
DO_COVERAGE=1
main() {
test_with_version 2 $*
test_with_version 3 $*
if command -v pypy > /dev/null; then
PYPY_PATH=`which pypy`
echo "Found PyPy at: ${PYPY_PATH}"
test_with_python pypy ${PYPY_PATH} $*
else
echo "Could not find PyPy"
fi
}
test_with_version() {
VERSION=$1
shift
if [[ `python -V 2>&1` == "Python $VERSION"* ]]; then
PYTHON_PATH=`which python`
elif [[ `python${VERSION} -V 2>&1` == "Python $VERSION"* ]]; then
PYTHON_PATH=`which python${VERSION}`
else
PYTHON_PATH=
fi
if [ ! -z "$PYTHON_PATH" ]; then
echo "Found Python ${VERSION} at: $PYTHON_PATH"
test_with_python ${VERSION} ${PYTHON_PATH} $*
else
echo "Could not find Python ${VERSION}"
fi
}
test_with_python() {
VERSION=$1
PYTHON_PATH=$2
shift 2
VENV_DIR=".tests/venvs/${VERSION}"
rm -rf ${VENV_DIR}
mkdir -p ${VENV_DIR}
virtualenv -p "$PYTHON_PATH" --no-site-packages "${VENV_DIR}"
source "${VENV_DIR}/bin/activate"
if [ $DO_COVERAGE -eq 1 ]; then
pip install coverage
fi
./test-with-current-python $*
if [ $DO_COVERAGE -eq 1 ]; then
find .tests/pythons -name .coverage | xargs coverage combine
coverage html
# Doing it once with the first python version is enough
DO_COVERAGE=0
fi
deactivate
}
main $*