Add a hook to allow overriding the remote module that's executed by execnet

This commit is contained in:
bwilson
2018-11-12 13:29:39 -06:00
parent 1efec5a153
commit 7fb7bd9d04
2 changed files with 13 additions and 1 deletions

View File

@@ -30,6 +30,11 @@ def pytest_xdist_rsyncfinish(source, gateways):
""" called after rsyncing a directory to remote gateways takes place. """ """ called after rsyncing a directory to remote gateways takes place. """
@pytest.mark.firstresult
def pytest_xdist_getremotemodule():
""" called when creating remote node"""
def pytest_configure_node(node): def pytest_configure_node(node):
""" configure node information before it gets instantiated. """ """ configure node information before it gets instantiated. """

View File

@@ -203,7 +203,13 @@ def make_reltoroot(roots, args):
class WorkerController(object): class WorkerController(object):
ENDMARK = -1 ENDMARK = -1
class RemoteHook:
@pytest.mark.trylast
def pytest_xdist_getremotemodule(self):
return xdist.remote
def __init__(self, nodemanager, gateway, config, putevent): def __init__(self, nodemanager, gateway, config, putevent):
config.pluginmanager.register(self.RemoteHook())
self.nodemanager = nodemanager self.nodemanager = nodemanager
self.putevent = putevent self.putevent = putevent
self.gateway = gateway self.gateway = gateway
@@ -242,7 +248,8 @@ class WorkerController(object):
basetemp = self.config._tmpdirhandler.getbasetemp() basetemp = self.config._tmpdirhandler.getbasetemp()
option_dict["basetemp"] = str(basetemp.join(name)) option_dict["basetemp"] = str(basetemp.join(name))
self.config.hook.pytest_configure_node(node=self) self.config.hook.pytest_configure_node(node=self)
self.channel = self.gateway.remote_exec(xdist.remote) remote_module = self.config.hook.pytest_xdist_getremotemodule()
self.channel = self.gateway.remote_exec(remote_module)
self.channel.send((self.workerinput, args, option_dict)) self.channel.send((self.workerinput, args, option_dict))
if self.putevent: if self.putevent:
self.channel.setcallback(self.process_from_remote, endmarker=self.ENDMARK) self.channel.setcallback(self.process_from_remote, endmarker=self.ENDMARK)