-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtests.sh
executable file
·53 lines (44 loc) · 1.38 KB
/
tests.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
#!/bin/sh
# Tests in these python interpreters or the default ones
PYTHONS=${PYTHONS:-"python3.8 python3.9 python3.10 python3.11 python3.12"}
# Check if docker is installed
if ! [ -x "$(command -v docker)" ]; then
echo "Docker is not installed. Please install docker and try again."
exit 1
fi
# Check if virtualenv is installed
if ! [ -x "$(command -v virtualenv)" ]; then
echo "Virtualenv is not installed. Please install virtualenv and try again."
exit 2
fi
# Check if pythons are installed
for PYTHON in $PYTHONS; do
if ! [ -x "$(command -v "$PYTHON")" ]; then
echo "$PYTHON is not installed. Please install $PYTHON and try again."
exit 3
fi
done
# Run test in each python interpreter
for PYTHON in $PYTHONS; do
echo "*** Testing in $PYTHON ***"
# Create virtualenv
virtualenv -p "$PYTHON" venv_test >/dev/null
. venv_test/bin/activate
echo " - Installing dependencies..."
${PYTHON} -m ensurepip --upgrade >/dev/null 2>&1 # This works in python3.12
pip install -e ".[dev]" >/dev/null
if [ $? -ne 0 ]; then
echo "Failed to install dependencies in $PYTHON!"
exit 4
fi
echo " - Running tests..."
pytest
if [ $? -ne 0 ]; then
echo "Tests failed in $PYTHON!"
(cd venv_test && docker compose down -v)
exit 5
fi
# Remove virtualenv
deactivate
rm -rf venv_test
done