[PATCH 1/3] python-utils-r1.eclass: Automatically enable '-p jobserver'

Michał Górny <[email protected]>
Newsgroups gmane.linux.gentoo.devel
Message-ID <[email protected]>
Automatically pass '-p jobserver' if running multiple jobs under
a jobserver, and dev-python/pytest-jobserver is intalled.  If it is not
installed, emit a warning since jobserver won't be respected.

Signed-off-by: Michał Górny <[email protected]>
---
 eclass/python-utils-r1.eclass | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 462126a47970d..e7c5ed4ee4d44 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -1588,6 +1588,17 @@ epytest() {
 				# jobs are unevenly distributed
 				--dist=worksteal
 			)
+
+			if [[ ${MAKEFLAGS} == *--jobserver-auth=* ]]; then
+				if has_version "dev-python/pytest-jobserver[${PYTHON_USEDEP}]"
+				then
+					args+=( -p jobserver )
+				elif [[ ! ${_EPYTEST_JOBSERVER_WARNED} ]]; then
+					ewarn "Jobserver found under pytest-xdist, but cannot be used without:"
+					ewarn "  dev-python/pytest-jobserver"
+					_EPYTEST_JOBSERVER_WARNED=1
+				fi
+			fi
 		fi
 	fi
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.