summaryrefslogtreecommitdiff
path: root/eclass/python-utils-r1.eclass
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2025-07-21 14:40:20 +0200
committerMichał Górny <mgorny@gentoo.org>2025-07-25 07:56:44 +0200
commit87a034bd840d2d9095bccb29e7cc0922ec29b4ad (patch)
tree7321f474e2f1995d1b98265825b4c0b0157c16c9 /eclass/python-utils-r1.eclass
parent44639f1f785d39247bf66c59b30f1d9ae9bd14b6 (diff)
downloadgentoo-87a034bd840d2d9095bccb29e7cc0922ec29b4ad.tar.gz
gentoo-87a034bd840d2d9095bccb29e7cc0922ec29b4ad.tar.bz2
gentoo-87a034bd840d2d9095bccb29e7cc0922ec29b4ad.zip
python-utils-r1.eclass: Add EPYTEST_RERUNS
Add EPYTEST_RERUNS variable to enable pytest-rerunfailures with a specified rerun count. This should provide a more streamlined approach to handling flaky test suites. Signed-off-by: Michał Górny <mgorny@gentoo.org> Part-of: https://github.com/gentoo/gentoo/pull/43094 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 9cdfdc87019f..13ed87501200 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -1354,6 +1354,16 @@ _set_epytest_plugins() {
fi
}
+# @ECLASS_VARIABLE: EPYTEST_RERUNS
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# If set to a non-empty value, enables pytest-rerunfailures plugin
+# and sets rerun count to the specified value. This variable can be
+# either set in ebuilds with flaky tests, or by user to try if it helps.
+# If this variable is set prior to calling distutils_enable_tests
+# in distutils-r1, a test dependency on dev-python/pytest-rerunfailures
+# is added automatically.
+
# @ECLASS_VARIABLE: EPYTEST_TIMEOUT
# @DEFAULT_UNSET
# @DESCRIPTION:
@@ -1517,6 +1527,18 @@ epytest() {
)
fi
+ if [[ -n ${EPYTEST_RERUNS} ]]; then
+ if [[ ${PYTEST_PLUGINS} != *pytest_rerunfailures* ]]; then
+ args+=(
+ -p rerunfailures
+ )
+ fi
+
+ args+=(
+ "--reruns=${EPYTEST_RERUNS}"
+ )
+ fi
+
if [[ -n ${EPYTEST_TIMEOUT} ]]; then
if [[ ${PYTEST_PLUGINS} != *pytest_timeout* ]]; then
args+=(