From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Cc: "Michał Górny" <mgorny@gentoo.org>
Subject: [gentoo-dev] [PATCH 3/5] python-utils-r1.eclass, distutils-r1.eclass: Add EPYTEST_TIMEOUT
Date: Thu, 4 Jan 2024 18:09:32 +0100 [thread overview]
Message-ID: <20240104170934.106565-3-mgorny@gentoo.org> (raw)
In-Reply-To: <20240104170934.106565-1-mgorny@gentoo.org>
Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
eclass/distutils-r1.eclass | 3 +++
eclass/python-utils-r1.eclass | 22 ++++++++++++++++++++++
2 files changed, 25 insertions(+)
diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
index 4e77237c3009..014669c8c47c 100644
--- a/eclass/distutils-r1.eclass
+++ b/eclass/distutils-r1.eclass
@@ -618,6 +618,9 @@ distutils_enable_tests() {
;;
pytest)
test_pkgs='>=dev-python/pytest-7.3.1[${PYTHON_USEDEP}]'
+ if [[ -n ${EPYTEST_TIMEOUT} ]]; then
+ test_pkgs+=' dev-python/pytest-timeout[${PYTHON_USEDEP}]'
+ fi
if [[ ${EPYTEST_XDIST} ]]; then
test_pkgs+=' dev-python/pytest-xdist[${PYTHON_USEDEP}]'
fi
diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 27fb92a75aca..22ab778b7e11 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
--
2.43.0
next prev parent reply other threads:[~2024-01-04 17:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-04 17:09 [gentoo-dev] [PATCH 1/5] python-utils-r1.eclass: Minimize pytest tempdir retention Michał Górny
2024-01-04 17:09 ` [gentoo-dev] [PATCH 2/5] dev-python/tox: epytest now takes care of removing tempdir Michał Górny
2024-01-04 17:09 ` Michał Górny [this message]
2024-01-04 17:09 ` [gentoo-dev] [PATCH 4/5] dev-python/trimesh: Use EPYTEST_TIMEOUT Michał Górny
2024-01-04 17:09 ` [gentoo-dev] [PATCH 5/5] distutils-r1.eclass: QA-warn about invalid package versions Michał Górny
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240104170934.106565-3-mgorny@gentoo.org \
--to=mgorny@gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox