forked from pypi/warehouse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests
executable file
·51 lines (44 loc) · 1.46 KB
/
tests
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
#!/bin/bash
set -e
# Click requires us to ensure we have a well configured environment to run
# our click commands. So we'll set our environment to ensure our locale is
# correct.
export LC_ALL="${ENCODING:-en_US.UTF-8}"
export LANG="${ENCODING:-en_US.UTF-8}"
export COVERAGE_PROCESS_START="$(pwd)/pyproject.toml"
# PEP 669 introduced sys.monitoring, a lighter-weight way to monitor
# the execution. Tell coverage to use this
# https://nedbatchelder.com/blog/202312/coveragepy_with_sysmonitoring.html
export COVERAGE_CORE="${COVERAGE_CORE:-sysmon}"
COMMAND_ARGS=( "$@" )
# Test the postgres connection
while [ $# -gt 0 ]; do
case $1 in
"--postgresql-host") POSTGRES_HOST="$2"
esac
shift
done
# Test the postgres connection
ATTEMPTS=0
until [ $ATTEMPTS -eq 12 ] || pg_isready -t 10 -h $POSTGRES_HOST; do
>&2 echo "Postgres is unavailable, sleeping"
sleep $(( ATTEMPTS++ ))
done
if [ $ATTEMPTS -eq 12 ]; then
>&2 echo "Postgres is unavailable, exiting"
exit 1
fi
# Print all the following commands
set -x
# Create any dist directories to silence whitenoise warnings.
mkdir -p warehouse/admin/static/dist/
mkdir -p warehouse/static/dist/
# Actually run our tests.
if [ "${COVERAGE:-yes}" != "no" ]; then
python -m coverage run -m pytest --strict-markers "${COMMAND_ARGS[@]}"
python -m coverage combine
python -m coverage html --show-contexts
python -m coverage report -m --fail-under 100 --skip-covered
else
python -m pytest --strict-markers "${COMMAND_ARGS[@]}"
fi;