-
-
Notifications
You must be signed in to change notification settings - Fork 107
Expand file tree
/
Copy pathtests.sh
More file actions
executable file
·107 lines (91 loc) · 2.54 KB
/
tests.sh
File metadata and controls
executable file
·107 lines (91 loc) · 2.54 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/usr/bin/env bash
# author: deadc0de6 (https://github.com/deadc0de6)
# Copyright (c) 2017, deadc0de6
# stop on first error
set -eu -o errtrace -o pipefail
cur=$(cd "$(dirname "${0}")" && pwd)
in_cicd="${GITHUB_ACTIONS:-}"
MULTI_PYTHON="" # set to test multi python envs
PYTHON_VERSIONS=("3.6" "3.7" "3.8" "3.9" "3.10" "3.11" "3.12" "3.13" "3.14")
test()
{
echo "=> python version:"
python3 --version
# test syntax
echo "checking syntax..."
"${cur}"/scripts/check-syntax.sh
# unittest
echo "unittest..."
"${cur}"/scripts/check-unittests.sh
# tests-ng
if [ -n "${in_cicd}" ]; then
# in CI/CD
export DOTDROP_WORKERS=1
echo "tests-ng with ${DOTDROP_WORKERS} worker(s)..."
"${cur}"/scripts/check-tests-ng.sh
export DOTDROP_WORKERS=4
echo "tests-ng with ${DOTDROP_WORKERS} worker(s)..."
"${cur}"/scripts/check-tests-ng.sh
else
echo "tests-ng..."
"${cur}"/scripts/check-tests-ng.sh
fi
}
if [ -n "${in_cicd}" ]; then
# patch TERM var in ci/cd
if [ -z "${TERM}" ]; then
export TERM="linux"
fi
fi
# make sure both version.py and manpage dotdrop.1 are in sync
dotdrop_version=$(grep version dotdrop/version.py | sed 's/^.*= .\(.*\).$/\1/g')
man_version=$(grep '^\.TH' manpage/dotdrop.1 | sed 's/^.*"dotdrop-\(.*\)\" "Save your.*$/\1/g')
if [ "${dotdrop_version}" != "${man_version}" ]; then
echo "ERROR version.py (${dotdrop_version}) and manpage (${man_version}) differ!"
exit 1
fi
echo "current dotdrop version ${dotdrop_version}"
if [ -n "${in_cicd}" ]; then
test
else
if [ -n "${MULTI_PYTHON}" ]; then
if ! hash pyenv &>/dev/null; then
echo "install pyenv"
exit 1
fi
eval "$(pyenv init -)"
for PY in "${PYTHON_VERSIONS[@]}"; do
echo "============== python ${PY} =============="
pyenv install -s "${PY}"
pyenv shell "${PY}"
python -m venv ".venv"
# shellcheck disable=SC1091
source ".venv/bin/activate"
pip install pip --upgrade
pip install -r requirements.txt
pip install -r tests-requirements.txt
test
deactivate
done
else
python3 -m venv ".venv"
# shellcheck disable=SC1091
source ".venv/bin/activate"
pip install pip --upgrade
pip install -r requirements.txt
pip install -r tests-requirements.txt
test
deactivate
fi
fi
# merge coverage
coverage combine coverages/*
coverage xml
# test doc
if [ -z "${in_cicd}" ]; then
# not in CI/CD
echo "checking documentation..."
"${cur}"/scripts/check-doc.sh
fi
## done
echo "All tests finished successfully"