From e0fac29676c44b996e61c06f8d5c92288e46966b Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Tue, 7 Nov 2023 10:17:51 +0000 Subject: gentoo auto-resync : 07:11:2023 - 10:17:51 --- eclass/Manifest.gz | Bin 38800 -> 38807 bytes eclass/distutils-r1.eclass | 32 +++++++++++++++++--------------- eclass/python-utils-r1.eclass | 31 +++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 15 deletions(-) (limited to 'eclass') diff --git a/eclass/Manifest.gz b/eclass/Manifest.gz index 1a69a031c4cb..e1736b48238d 100644 Binary files a/eclass/Manifest.gz and b/eclass/Manifest.gz differ diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass index 1cc91110dccf..3d756eaad556 100644 --- a/eclass/distutils-r1.eclass +++ b/eclass/distutils-r1.eclass @@ -608,18 +608,28 @@ distutils_enable_tests() { esac [[ ${#} -eq 1 ]] || die "${FUNCNAME} takes exactly one argument: test-runner" - local test_pkg + + local test_deps=${RDEPEND} + local test_pkgs case ${1} in nose) - test_pkg=">=dev-python/nose-1.3.7_p20221026" + test_pkgs='>=dev-python/nose-1.3.7_p20221026[${PYTHON_USEDEP}]' ;; pytest) - test_pkg=">=dev-python/pytest-7.3.1" + test_pkgs='>=dev-python/pytest-7.3.1[${PYTHON_USEDEP}]' + if [[ ${EPYTEST_XDIST} ]]; then + test_pkgs+=' dev-python/pytest-xdist[${PYTHON_USEDEP}]' + fi ;; setup.py) ;; unittest) - # dep handled below + # unittest-or-fail is needed in py<3.12 + test_deps+=" + $(python_gen_cond_dep ' + dev-python/unittest-or-fail[${PYTHON_USEDEP}] + ' 3.10 3.11) + " ;; *) die "${FUNCNAME}: unsupported argument: ${1}" @@ -628,22 +638,14 @@ distutils_enable_tests() { _DISTUTILS_TEST_RUNNER=${1} python_test() { distutils-r1_python_test; } - local test_deps=${RDEPEND} - if [[ -n ${test_pkg} ]]; then + if [[ -n ${test_pkgs} ]]; then if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then - test_deps+=" ${test_pkg}[${PYTHON_USEDEP}]" + test_deps+=" ${test_pkgs//'${PYTHON_USEDEP}'/${PYTHON_USEDEP}}" else test_deps+=" $(python_gen_cond_dep " - ${test_pkg}[\${PYTHON_USEDEP}] + ${test_pkgs} ")" fi - elif [[ ${1} == unittest ]]; then - # unittest-or-fail is needed in py<3.12 - test_deps+=" - $(python_gen_cond_dep ' - dev-python/unittest-or-fail[${PYTHON_USEDEP}] - ' 3.{9..11}) - " fi if [[ -n ${test_deps} ]]; then IUSE+=" test" diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass index 4a538f9942f6..80abe974f9df 100644 --- a/eclass/python-utils-r1.eclass +++ b/eclass/python-utils-r1.eclass @@ -1307,6 +1307,21 @@ _python_check_occluded_packages() { # parameter, when calling epytest. The listed files will be entirely # skipped from test collection. +# @ECLASS_VARIABLE: EPYTEST_XDIST +# @DEFAULT_UNSET +# @DESCRIPTION: +# If set to a non-empty value, enables running tests in parallel +# via pytest-xdist plugin. If this variable is set prior to calling +# distutils_enable_tests in distutils-r1, a test dependency +# on dev-python/pytest-xdist is added automatically. + +# @ECLASS_VARIABLE: EPYTEST_JOBS +# @USER_VARIABLE +# @DEFAULT_UNSET +# @DESCRIPTION: +# Specifies the number of jobs for parallel (pytest-xdist) test runs. +# When unset, defaults to -j from MAKEOPTS, or the current nproc. + # @FUNCTION: epytest # @USAGE: [...] # @DESCRIPTION: @@ -1371,6 +1386,22 @@ epytest() { -p no:plus -p no:tavern ) + + if [[ ${EPYTEST_XDIST} ]]; then + local jobs=${EPYTEST_JOBS:-$(makeopts_jobs)} + if [[ ${jobs} -gt 1 ]]; then + args+=( + # explicitly enable the plugin, in case the ebuild was using + # PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 + -p xdist + -n "${jobs}" + # worksteal ensures that workers don't end up idle when heavy + # jobs are unevenly distributed + --dist=worksteal + ) + fi + fi + local x for x in "${EPYTEST_DESELECT[@]}"; do args+=( --deselect "${x}" ) -- cgit v1.2.3