Skip to content

Commit 6bf9672

Browse files
committed
Use Config.invocation_params for identical worker and master initialization
1 parent a19d74d commit 6bf9672

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

src/xdist/remote.py

+13-6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
import pytest
1616
from execnet.gateway_base import dumps, DumpError
1717

18+
from _pytest.config import _prepareconfig, Config
19+
1820

1921
class WorkerInteractor(object):
2022
def __init__(self, config, channel):
@@ -211,18 +213,18 @@ def getinfodict():
211213

212214

213215
def remote_initconfig(option_dict, args):
214-
from _pytest.config import Config
215-
216216
option_dict["plugins"].append("no:terminal")
217-
config = Config.fromdictargs(option_dict, args)
217+
return Config.fromdictargs(option_dict, args)
218+
219+
220+
def setup_config(config, basetemp):
218221
config.option.looponfail = False
219222
config.option.usepdb = False
220223
config.option.dist = "no"
221224
config.option.distload = False
222225
config.option.numprocesses = None
223226
config.option.maxprocesses = None
224-
config.args = args
225-
return config
227+
config.option.basetemp = basetemp
226228

227229

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

242-
config = remote_initconfig(option_dict, args)
244+
if hasattr(Config, "InvocationParams"):
245+
config = _prepareconfig(args, None)
246+
else:
247+
config = remote_initconfig(option_dict, args)
248+
249+
setup_config(config, option_dict.get("basetemp"))
243250
config._parser.prog = os.path.basename(workerinput["mainargv"][0])
244251
config.workerinput = workerinput
245252
config.workeroutput = {}

src/xdist/workermanage.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,8 @@ def make_reltoroot(roots, args):
186186
for arg in args:
187187
parts = arg.split(splitcode)
188188
fspath = py.path.local(parts[0])
189+
if not fspath.exists():
190+
continue
189191
for root in roots:
190192
x = fspath.relto(root)
191193
if x or fspath == root:
@@ -236,10 +238,14 @@ def shutting_down(self):
236238
def setup(self):
237239
self.log("setting up worker session")
238240
spec = self.gateway.spec
239-
args = self.config.args
241+
if hasattr(self.config, "invocation_params"):
242+
args = [str(x) for x in self.config.invocation_params.args or ()]
243+
option_dict = {}
244+
else:
245+
args = self.config.args
246+
option_dict = vars(self.config.option)
240247
if not spec.popen or spec.chdir:
241248
args = make_reltoroot(self.nodemanager.roots, args)
242-
option_dict = vars(self.config.option)
243249
if spec.popen:
244250
name = "popen-%s" % self.gateway.id
245251
if hasattr(self.config, "_tmpdirhandler"):

0 commit comments

Comments
 (0)