common/build-style/python3-*: add support for pytest-xdist

if python3-pytest-xdist is included in checkdepends, use $XBPS_MAKEJOBS
to run tests in parallel.
This commit is contained in:
classabbyamp 2022-05-14 15:23:13 -04:00 committed by Andrew J. Hesford
parent 711ee9b13f
commit c011e0e13b
2 changed files with 10 additions and 2 deletions

View File

@ -24,10 +24,14 @@ do_build() {
}
do_check() {
local testjobs
if python3 -c 'import pytest' >/dev/null 2>&1; then
if python3 -c 'import xdist' >/dev/null 2>&1; then
testjobs="-n $XBPS_MAKEJOBS"
fi
PYTHONPATH="$(cd build/lib* && pwd)" \
${make_check_pre} \
python3 -m pytest ${make_check_args} ${make_check_target}
python3 -m pytest ${testjobs} ${make_check_args} ${make_check_target}
else
# Fall back to deprecated setup.py test orchestration without pytest
if [ -z "$make_check_target" ]; then

View File

@ -13,8 +13,12 @@ do_build() {
}
do_check() {
local testjobs
if python3 -c 'import pytest' >/dev/null 2>&1; then
${make_check_pre} python3 -m pytest ${make_check_args} ${make_check_target}
if python3 -c 'import xdist' >/dev/null 2>&1; then
testjobs="-n $XBPS_MAKEJOBS"
fi
${make_check_pre} python3 -m pytest ${testjobs} ${make_check_args} ${make_check_target}
else
msg_warn "Unable to determine tests for PEP517 Python templates"
return 0