1
0
Fork 1
mirror of https://gitlab.postmarketos.org/postmarketOS/pmbootstrap.git synced 2025-07-12 19:09:56 +03:00
pmbootstrap/.ci/pytest.sh
Caleb Connolly e268ec24d5
pytest: generate coverage and junit reports (MR 2478)
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-11-04 10:46:11 +01:00

39 lines
895 B
Bash
Executable file

#!/bin/sh -e
# Description: run pmbootstrap python testsuite
# Options: native slow
# https://postmarketos.org/pmb-ci
if [ "$(id -u)" = 0 ]; then
set -x
apk -q add \
git \
openssl \
py3-pytest \
py3-pytest-cov \
sudo
exec su "${TESTUSER:-build}" -c "sh -e $0"
fi
# Require pytest to be installed on the host system
if [ -z "$(command -v pytest)" ]; then
echo "ERROR: pytest command not found, make sure it is in your PATH."
exit 1
fi
# Use pytest-cov if it is installed to display code coverage
cov_arg=""
if python -c "import pytest_cov" >/dev/null 2>&1; then
cov_arg="--cov=pmb --cov-report term --cov-report xml:coverage.xml"
fi
echo "Running pytest..."
echo "NOTE: use 'pmbootstrap log' to see the detailed log if running locally."
# shellcheck disable=SC2086
python -m pytest \
--color=yes \
-vv \
-x \
--junitxml=junit.xml \
$cov_arg \
-m "not skip_ci" \
"$@"