summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2024-01-03 14:32:33 +0100
committerMichał Górny <mgorny@gentoo.org>2024-01-05 21:18:53 +0100
commit635892e8f096afd7d1f3ea2f91a6906122b2e5ca (patch)
treebe39df340d264b70ce562c0b84d79b14ca958595 /eclass/python-utils-r1.eclass
parentdev-python/tox: epytest now takes care of removing tempdir (diff)
downloadgentoo-635892e8f096afd7d1f3ea2f91a6906122b2e5ca.tar.gz
gentoo-635892e8f096afd7d1f3ea2f91a6906122b2e5ca.tar.bz2
gentoo-635892e8f096afd7d1f3ea2f91a6906122b2e5ca.zip
python-utils-r1.eclass, distutils-r1.eclass: Add EPYTEST_TIMEOUT
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'eclass/python-utils-r1.eclass')
-rw-r--r--eclass/python-utils-r1.eclass22
1 files changed, 22 insertions, 0 deletions
diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index a82379ce876b..3af3cbdb075e 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -1296,6 +1296,16 @@ _python_check_occluded_packages() {
# parameter, when calling epytest. The listed files will be entirely
# skipped from test collection.
+# @ECLASS_VARIABLE: EPYTEST_TIMEOUT
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# If set to a non-empty value, enables pytest-timeout plugin and sets
+# test timeout to the specified value. This variable can be either set
+# in ebuilds that are known to hang, or by user to prevent hangs
+# in automated test environments. If this variable is set prior
+# to calling distutils_enable_tests in distutils-r1, a test dependency
+# on dev-python/pytest-timeout is added automatically.
+
# @ECLASS_VARIABLE: EPYTEST_XDIST
# @DEFAULT_UNSET
# @DESCRIPTION:
@@ -1381,6 +1391,18 @@ epytest() {
)
fi
+ if [[ -n ${EPYTEST_TIMEOUT} ]]; then
+ if [[ ${PYTEST_PLUGINS} != *pytest_timeout* ]]; then
+ args+=(
+ -p timeout
+ )
+ fi
+
+ args+=(
+ "--timeout=${EPYTEST_TIMEOUT}"
+ )
+ fi
+
if [[ ${EPYTEST_XDIST} ]]; then
local jobs=${EPYTEST_JOBS:-$(makeopts_jobs)}
if [[ ${jobs} -gt 1 ]]; then