From ae74dc2172d7f633d2e52d30aec79fbb0ae9ed63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mark=C3=A9ta=20Cal=C3=A1bkov=C3=A1?= Date: Mon, 31 Aug 2020 15:26:22 +0200 Subject: [PATCH] Revert "Finish removal of "slave" terminology" This reverts commit de3e54fd278d49b9b5d64e64f5942512519545e5. Updated on 2022-01-15 --- setup.cfg | 2 +- src/xdist/dsession.py | 3 +++ src/xdist/plugin.py | 5 ++++- src/xdist/remote.py | 3 +++ src/xdist/workermanage.py | 6 +++++- testing/acceptance_test.py | 16 ++++++++++++++++ 6 files changed, 32 insertions(+), 3 deletions(-) --- a/setup.cfg 2021-12-10 12:41:52.000000000 +0100 +++ b/setup.cfg 2022-01-15 18:37:44.047576974 +0100 @@ -38,7 +38,7 @@ zip_safe = False python_requires = >=3.6 install_requires = execnet>=1.1 - pytest>=6.2.0 + pytest>=4.4.0 pytest-forked setup_requires = setuptools_scm>=6.0 --- a/src/xdist/dsession.py 2021-12-10 12:41:44.000000000 +0100 +++ b/src/xdist/dsession.py 2022-01-15 18:39:21.407575231 +0100 @@ -155,6 +155,9 @@ class DSession: node.workerinfo["id"] = node.gateway.id node.workerinfo["spec"] = node.gateway.spec + # TODO: (#234 task) needs this for pytest. Remove when refactor in pytest repo + node.slaveinfo = node.workerinfo + self.config.hook.pytest_testnodeready(node=node) if self.shuttingdown: node.shutdown() --- a/src/xdist/plugin.py 2021-12-10 12:41:44.000000000 +0100 +++ b/src/xdist/plugin.py 2022-01-15 18:40:33.771573935 +0100 @@ -76,11 +76,14 @@ def pytest_addoption(parser): ) group.addoption( "--max-worker-restart", + "--max-slave-restart", action="store", default=None, dest="maxworkerrestart", help="maximum number of workers that can be restarted " - "when crashed (set to zero to disable this feature)", + "when crashed (set to zero to disable this feature)\n" + "'--max-slave-restart' option is deprecated and will be removed in " + "a future release", ) group.addoption( "--dist", --- a/src/xdist/remote.py 2021-12-10 12:41:44.000000000 +0100 +++ b/src/xdist/remote.py 2022-01-15 18:41:44.115572675 +0100 @@ -287,5 +287,8 @@ if __name__ == "__channelexec__": config._parser.prog = os.path.basename(workerinput["mainargv"][0]) config.workerinput = workerinput # type: ignore[attr-defined] config.workeroutput = {} # type: ignore[attr-defined] + # TODO: deprecated name, backward compatibility only. Remove it in future + config.slaveinput = config.workerinput + config.slaveoutput = config.workeroutput interactor = WorkerInteractor(config, channel) # type: ignore[name-defined] config.hook.pytest_cmdline_main(config=config) --- a/src/xdist/workermanage.py 2021-12-10 12:41:44.000000000 +0100 +++ b/src/xdist/workermanage.py 2022-01-15 18:43:34.595570697 +0100 @@ -225,9 +225,13 @@ class WorkerController: self.workerinput = { "workerid": gateway.id, "workercount": len(nodemanager.specs), + "slaveid": gateway.id, + "slavecount": len(nodemanager.specs), "testrunuid": nodemanager.testrunuid, "mainargv": sys.argv, } + # TODO: deprecated name, backward compatibility only. Remove it in future + self.slaveinput = self.workerinput self._down = False self._shutdown_sent = False self.log = py.log.Producer("workerctl-%s" % gateway.id) @@ -329,7 +333,7 @@ class WorkerController: self.notify_inproc(eventname, node=self, **kwargs) elif eventname == "workerfinished": self._down = True - self.workeroutput = kwargs["workeroutput"] + self.workeroutput = self.slaveoutput = kwargs["workeroutput"] self.notify_inproc("workerfinished", node=self) elif eventname in ("logstart", "logfinish"): self.notify_inproc(eventname, node=self, **kwargs) --- a/testing/acceptance_test.py 2021-12-10 12:41:44.000000000 +0100 +++ b/testing/acceptance_test.py 2022-01-15 18:44:54.711569262 +0100 @@ -247,6 +247,22 @@ class TestDistribution: result.stderr.fnmatch_lines(["--foobar=123 active! *"]) assert dest.joinpath(subdir.name).is_dir() + def test_backward_compatibility_worker_terminology(self, testdir): + """Ensure that we still support "config.slaveinput" for backward compatibility (#234). + + Keep in mind that removing this compatibility will break a ton of plugins and user code. + """ + testdir.makepyfile( + """ + def test(pytestconfig): + assert hasattr(pytestconfig, 'slaveinput') + assert hasattr(pytestconfig, 'workerinput') + """ + ) + result = testdir.runpytest("-n1") + result.stdout.fnmatch_lines("*1 passed*") + assert result.ret == 0 + def test_data_exchange(self, pytester: pytest.Pytester) -> None: pytester.makeconftest( """