Skip to content

Commit

Permalink
Use Config.invocation_params for identical worker and master initiali…
Browse files Browse the repository at this point in the history
…zation
  • Loading branch information
nicoddemus committed Jul 10, 2019
1 parent a19d74d commit 6bf9672
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
19 changes: 13 additions & 6 deletions src/xdist/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import pytest
from execnet.gateway_base import dumps, DumpError

from _pytest.config import _prepareconfig, Config


class WorkerInteractor(object):
def __init__(self, config, channel):
Expand Down Expand Up @@ -211,18 +213,18 @@ def getinfodict():


def remote_initconfig(option_dict, args):
from _pytest.config import Config

option_dict["plugins"].append("no:terminal")
config = Config.fromdictargs(option_dict, args)
return Config.fromdictargs(option_dict, args)


def setup_config(config, basetemp):
config.option.looponfail = False
config.option.usepdb = False
config.option.dist = "no"
config.option.distload = False
config.option.numprocesses = None
config.option.maxprocesses = None
config.args = args
return config
config.option.basetemp = basetemp


if __name__ == "__channelexec__":
Expand All @@ -239,7 +241,12 @@ def remote_initconfig(option_dict, args):
os.environ["PYTEST_XDIST_WORKER"] = workerinput["workerid"]
os.environ["PYTEST_XDIST_WORKER_COUNT"] = str(workerinput["workercount"])

config = remote_initconfig(option_dict, args)
if hasattr(Config, "InvocationParams"):
config = _prepareconfig(args, None)
else:
config = remote_initconfig(option_dict, args)

setup_config(config, option_dict.get("basetemp"))
config._parser.prog = os.path.basename(workerinput["mainargv"][0])
config.workerinput = workerinput
config.workeroutput = {}
Expand Down
10 changes: 8 additions & 2 deletions src/xdist/workermanage.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ def make_reltoroot(roots, args):
for arg in args:
parts = arg.split(splitcode)
fspath = py.path.local(parts[0])
if not fspath.exists():
continue
for root in roots:
x = fspath.relto(root)
if x or fspath == root:
Expand Down Expand Up @@ -236,10 +238,14 @@ def shutting_down(self):
def setup(self):
self.log("setting up worker session")
spec = self.gateway.spec
args = self.config.args
if hasattr(self.config, "invocation_params"):
args = [str(x) for x in self.config.invocation_params.args or ()]
option_dict = {}
else:
args = self.config.args
option_dict = vars(self.config.option)
if not spec.popen or spec.chdir:
args = make_reltoroot(self.nodemanager.roots, args)
option_dict = vars(self.config.option)
if spec.popen:
name = "popen-%s" % self.gateway.id
if hasattr(self.config, "_tmpdirhandler"):
Expand Down

0 comments on commit 6bf9672

Please sign in to comment.