spiegel-keyman/linux/keyman-config/run-tests.sh
Eberhard Beilharz 397b5bdf93
maint(linux): streamline use of env variables to detect running on TC
This changes the variable we use to detect if we're running on TC to
be the same as the one used on #13810.
2025-05-06 11:49:59 +02:00

41 lines
1.5 KiB
Bash
Executable file

#!/bin/bash
PYTHONPATH=.:${PYTHONPATH}
XDG_CONFIG_HOME=$(mktemp --directory)
export XDG_CONFIG_HOME
if [[ -f /usr/libexec/ibus-memconf ]]; then
export GSETTINGS_BACKEND=keyfile
fi
if [[ "$1" == "--coverage" ]]; then
coverage="-m coverage run --source=. --data-file=build/.coverage"
fi
if [[ -n "${TEAMCITY_GIT_PATH}" ]]; then
if ! pip3 list --format=columns | grep -q teamcity-messages; then
if [[ -n "${TEAMCITY_PLATFORM}" ]] || [[ -n "${DOCKER_RUNNING}" ]]; then
# Ubuntu 24.04+ prevents mixing pip and system packages and wants us
# to use a virtualenv. However, that causes other problems, so we
# override this check only if we're running in a TC agent or docker
# so that we don't accidentally break the local system.
# Note: it is intentional that we use TEAMCITY_GIT_PATH as well
# as TEAMCITY_PLATFORM here so that it is possible to simulate
# running in a TC agent and still not break your local system
# (run in a docker container or explicitly set TEAMCITY_PLATFORM
# to cause the script to install the package).
PIP_ARGS="--break-system-packages"
fi
# shellcheck disable=SC2086
pip3 install --user ${PIP_ARGS:-} teamcity-messages
fi
test_module=teamcity.unittestpy
else
test_module=unittest
extra_opts=-v
fi
# shellcheck disable=SC2086
python3 ${coverage:-} -m "${test_module:-}" discover ${extra_opts:-} -s tests/ -p "*_tests.py"
rm -rf "${XDG_CONFIG_HOME}"