eclass/python-utils-r1: Sync with Gentoo

It's from Gentoo commit 171a72e48ca08dd7d5f1a0f9c00d5a3297db1239.
This commit is contained in:
Flatcar Buildbot 2023-11-27 07:12:54 +00:00 committed by Krzesimir Nowak
parent b21400bb72
commit 5267f20799

View File

@ -1307,6 +1307,21 @@ _python_check_occluded_packages() {
# parameter, when calling epytest. The listed files will be entirely # parameter, when calling epytest. The listed files will be entirely
# skipped from test collection. # 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 # @FUNCTION: epytest
# @USAGE: [<args>...] # @USAGE: [<args>...]
# @DESCRIPTION: # @DESCRIPTION:
@ -1347,6 +1362,10 @@ epytest() {
# count is more precise when we're dealing with a large number # count is more precise when we're dealing with a large number
# of tests # of tests
-o console_output_style=count -o console_output_style=count
)
if [[ ! ${PYTEST_DISABLE_PLUGIN_AUTOLOAD} ]]; then
args+=(
# disable the undesirable-dependency plugins by default to # disable the undesirable-dependency plugins by default to
# trigger missing argument strips. strip options that require # trigger missing argument strips. strip options that require
# them from config files. enable them explicitly via "-p ..." # them from config files. enable them explicitly via "-p ..."
@ -1371,6 +1390,27 @@ epytest() {
-p no:plus -p no:plus
-p no:tavern -p no:tavern
) )
fi
if [[ ${EPYTEST_XDIST} ]]; then
local jobs=${EPYTEST_JOBS:-$(makeopts_jobs)}
if [[ ${jobs} -gt 1 ]]; then
if [[ ${PYTEST_PLUGINS} != *xdist.plugin* ]]; then
args+=(
# explicitly enable the plugin, in case the ebuild was
# using PYTEST_DISABLE_PLUGIN_AUTOLOAD=1
-p xdist
)
fi
args+=(
-n "${jobs}"
# worksteal ensures that workers don't end up idle when heavy
# jobs are unevenly distributed
--dist=worksteal
)
fi
fi
local x local x
for x in "${EPYTEST_DESELECT[@]}"; do for x in "${EPYTEST_DESELECT[@]}"; do
args+=( --deselect "${x}" ) args+=( --deselect "${x}" )