dev-python/pytest-jobserver: Remove old

Signed-off-by: Michał Górny <mgorny@gentoo.org>
This commit is contained in:
Michał Górny
2026-04-04 20:25:26 +02:00
parent 2f3e78817f
commit 0178eb80f6
3 changed files with 0 additions and 180 deletions

View File

@@ -1,3 +1,2 @@
DIST pytest-jobserver-1.0.0.tar.gz 6286 BLAKE2B 88020a09b605c52745761e22e925329ef18f3c1f5bb69c92f430621eb454810f6e533135959a59c19e557c1cc98e1c808ae2b5917e0e947f1d01579ce25918b0 SHA512 e98d3908357930e3ee11082e88477c4225e86c7a357ac0e9120ebd75b3cc6ffa38d65fc37d72bbcf35530fe0949badd9c6a1ccb7a370d1ca6ae69c9694ba8e48
DIST pytest_jobserver-1.1.0.tar.gz 11754 BLAKE2B 94954dc6db8b1a698701bb6cb4e9c190526e7874a440c9059d8b251e5ffec899229de4a4d1f9b1e74c1e1fbf390a78179d5b2957d1bb4db7b88e6fc9dea27f59 SHA512 0d6dfde282fe060ac187d9475fc8a6600254341ae7a062f95c9ef259a94bfaaab4e374363651989ecff3fbd8b2603a5802effbb53692dfa5b1658a1715239221
DIST pytest_jobserver-1.1.0.tar.gz.provenance 9701 BLAKE2B e6fb380757ae3f7843fc3e04e02aa4381f66432738df6ee29a2d17f280128344e61172ac294bfdc88a09fd937a2617ff276ed0232d3693303c2fd0332170d9a1 SHA512 423e35342da9a76e668243b69f5dba305c4699ab8a50b1ba6a9622b249bb031afda85f4b63ccf4e5e7fbcd56a9abdea066f2d096edb76aa28ad6da262bb7cd38

View File

@@ -1,125 +0,0 @@
diff --git a/pytest_jobserver/configure.py b/pytest_jobserver/configure.py
index aa3c998..364729d 100644
--- a/pytest_jobserver/configure.py
+++ b/pytest_jobserver/configure.py
@@ -21,9 +21,6 @@ def path_to_file_descriptors(jobserver_path: str) -> Optional[FileDescriptorsRW]
if os.path.exists(jobserver_path) is False:
raise pytest.UsageError("jobserver doesn't exist: {}".format(jobserver_path))
- if is_fifo(jobserver_path) is False:
- raise pytest.UsageError("jobserver is not a fifo: {}".format(jobserver_path))
-
if is_rw_ok(jobserver_path) is False:
raise pytest.UsageError(
"jobserver is not read/writeable to current user: {}".format(jobserver_path)
@@ -50,16 +47,19 @@ def jobserver_from_env_make(config: Config) -> Optional[FileDescriptorsRW]:
parser = argparse.ArgumentParser(prog="makeflags")
parser.add_argument("--jobserver-fds", default=None)
- parser.add_argument("--jobserver-auth", default=None)
+ parser.add_argument("--jobserver-auth", default="")
args, _ = parser.parse_known_args(shlex.split(makeflags))
+ if args.jobserver_auth.startswith("fifo:"):
+ return path_to_file_descriptors(args.jobserver_auth[5:])
+
fds = args.jobserver_fds or args.jobserver_auth
if fds is None:
return None
if config.pluginmanager.hasplugin("xdist"):
raise pytest.UsageError(
- "pytest-jobserver does not support using pytest-xdist with MAKEFLAGS"
+ "pytest-jobserver does not support using pytest-xdist with fd-based jobserver in MAKEFLAGS"
)
fd_read, fd_write = tuple(FileDescriptor(int(fd)) for fd in fds.split(","))
diff --git a/pytest_jobserver/plugin.py b/pytest_jobserver/plugin.py
index fc4f11c..c3b781e 100644
--- a/pytest_jobserver/plugin.py
+++ b/pytest_jobserver/plugin.py
@@ -23,16 +23,29 @@ class JobserverPlugin(object):
self._fd_read, self._fd_write = fds
self._thread_locals = threading.local()
+ @pytest.hookimpl(hookwrapper=True, tryfirst=True)
+ def pytest_collection(self, session: pytest.Session) -> Iterator[Any]:
+ if os.environ.get("PYTEST_XDIST_WORKER", "gw0") != "gw0":
+ token = os.read(self._fd_read, 1)
+ yield
+ os.write(self._fd_write, token)
+ else:
+ yield
+
@pytest.hookimpl(hookwrapper=True, tryfirst=True)
def pytest_runtest_protocol(self, item: Item) -> Iterator[Any]:
- token = os.read(self._fd_read, 1)
- self._thread_locals.token = ord(token)
- yield
- os.write(self._fd_write, token)
+ if os.environ.get("PYTEST_XDIST_WORKER", "gw0") != "gw0":
+ token = os.read(self._fd_read, 1)
+ self._thread_locals.token = ord(token)
+ yield
+ os.write(self._fd_write, token)
+ else:
+ self._thread_locals.token = None
+ yield
@pytest.fixture(scope="function", autouse=True)
- def jobserver_token(self, request: Any) -> int:
- int_token: int = self._thread_locals.token
+ def jobserver_token(self, request: Any) -> int | None:
+ int_token: int | None = self._thread_locals.token
return int_token
def pytest_report_header(self, config: Config) -> str:
diff --git a/pytest_jobserver/test/test_plugin.py b/pytest_jobserver/test/test_plugin.py
index 6f51376..45cce4d 100644
--- a/pytest_jobserver/test/test_plugin.py
+++ b/pytest_jobserver/test/test_plugin.py
@@ -68,6 +68,25 @@ def test_config_env_pytest(testdir: TestDir) -> None:
assert result.ret == 0
+def test_config_makeflags_pytest(testdir: TestDir) -> None:
+ testdir.makepyfile(
+ """
+ def test_pass(request):
+ pass
+ """
+ )
+ make_jobserver(testdir.tmpdir, "jobserver_fifo", 1)
+ testdir.monkeypatch.setenv("MAKEFLAGS", "--jobserver-auth=fifo:jobserver_fifo")
+
+ result = testdir.runpytest("-v")
+
+ result.stdout.fnmatch_lines(["*::test_pass PASSED*"])
+ result.stdout.fnmatch_lines(
+ ["jobserver: configured at file descriptors (read: *, write: *)"]
+ )
+ assert result.ret == 0
+
+
def test_jobserver_token_fixture(testdir: TestDir) -> None:
testdir.makepyfile(
f"""
@@ -94,7 +113,9 @@ def test_xdist_makeflags_fails(testdir: TestDir) -> None:
result = testdir.runpytest("-v", "-n2")
assert result.ret == 4, "Expected pytest would fail to run with MAKEFLAGS and xdist"
result.stderr.fnmatch_lines(
- ["ERROR: pytest-jobserver does not support using pytest-xdist with MAKEFLAGS"]
+ [
+ "ERROR: pytest-jobserver does not support using pytest-xdist with fd-based jobserver in MAKEFLAGS"
+ ]
)
@@ -166,6 +187,7 @@ def test_server_not_found(testdir: TestDir) -> None:
def test_server_not_fifo(testdir: TestDir) -> None:
+ return
testdir.makefile(".txt", jobserver="X")
testdir.makepyfile(
"""

View File

@@ -1,54 +0,0 @@
# Copyright 2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
DISTUTILS_USE_PEP517=setuptools
PYPI_NO_NORMALIZE=1
PYTHON_COMPAT=( pypy3_11 python3_{11..14} python3_{13..14}t )
inherit distutils-r1 pypi
DESCRIPTION="Limit parallel tests with POSIX jobserver"
HOMEPAGE="
https://github.com/tommilligan/pytest-jobserver/
https://pypi.org/project/pytest-jobserver/
"
LICENSE="Apache-2.0"
SLOT="0"
KEYWORDS="~amd64"
RDEPEND="
dev-python/pytest[${PYTHON_USEDEP}]
"
PATCHES=(
# Combined Gentoo patches:
# 1. Update MAKEFLAGS parsing:
# https://github.com/tommilligan/pytest-jobserver/pull/147
# 2. Do not require FIFO:
# https://github.com/tommilligan/pytest-jobserver/pull/149
# 3. Acquire job tokens for test collection:
# https://github.com/tommilligan/pytest-jobserver/pull/150
# 4. Do not acquire tokens for gw0 (not submitted yet).
"${FILESDIR}/${P}-gentoo.patch"
)
EPYTEST_PLUGIN_LOAD_VIA_ENV=1
EPYTEST_PLUGINS=( "${PN}" pytest-xdist )
distutils_enable_tests pytest
python_test() {
local EPYTEST_DESELECT=(
pytest_jobserver/test/test_plugin.py::test_xdist_makeflags_fails
# broken by implicit slot fix
pytest_jobserver/test/test_plugin.py::test_jobserver_token_fixture
pytest_jobserver/test/test_plugin.py::test_server_xdist
)
unset A MAKEFLAGS
# missing conftest.py
epytest -p pytester
}