-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathruntests
executable file
·36 lines (30 loc) · 1.02 KB
/
runtests
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/sh
# Check for python3
command -v python3 >/dev/null 2>&1 || { echo >&2 "Tests require python3, which was not detected. Aborting."; exit 1; }
TESTDIR=`dirname $0`/tests
TESTENV="$TESTDIR/testenv"
echo Setting up test execution environment...
# Check for virtual environment
if [ ! -d "$TESTENV" ]; then
command -v virtualenv >/dev/null 2>&1
if [ $? -eq 0 ]; then
# Just use virtualenv.
virtualenv -p `which python3` "$TESTENV" || exit 1
else
# Check for specific version
python3 -c "import sys; sys.exit(0 if sys.version_info >= (3, 3, 0) else 1)"
if [ $? -eq 0 ]; then
# If at least 3.3, we can simply use venv module.
python3 -m venv "$TESTENV" || exit 1
else
echo Please install virtualenv to run tests
exit 1
fi
fi
fi
# Make sure requirements are up-to-date
"$TESTENV/bin/pip" install -r "$TESTDIR/requirements.txt"
# Run tests
echo Running tests...
cd $TESTDIR
testenv/bin/python -m unittest $* tests.py