Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix regression with custom arguments being dropped in non-local executions #491

Merged
merged 9 commits into from
Dec 20, 2019
1 change: 1 addition & 0 deletions src/xdist/workermanage.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ def make_reltoroot(roots, args):
parts = arg.split(splitcode)
fspath = py.path.local(parts[0])
if not fspath.exists():
result.append(arg)
continue
for root in roots:
x = fspath.relto(root)
Expand Down
8 changes: 7 additions & 1 deletion testing/acceptance_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,12 @@ def test_distribution_rsyncdirs_example(self, testdir):
subdir.ensure("__init__.py")
p = subdir.join("test_one.py")
p.write("def test_5():\n assert not __file__.startswith(%r)" % str(p))
result = testdir.runpytest(
result = testdir.runpytest_subprocess(
"-v",
"-d",
"-s",
"--foobar=123",
"--dist=load",
"--rsyncdir=%(subdir)s" % locals(),
"--tx=popen//chdir=%(dest)s" % locals(),
p,
Expand All @@ -209,6 +212,9 @@ def test_distribution_rsyncdirs_example(self, testdir):
"*1 passed*",
]
)
result.stderr.fnmatch_lines(
["--foobar=123 active! *", "--foobar=123 active! *"]
)
assert dest.join(subdir.basename).check(dir=1)

def test_backward_compatibility_worker_terminology(self, testdir):
Expand Down
16 changes: 16 additions & 0 deletions testing/foobar/foobarplugin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from __future__ import print_function

import os
import sys

import pytest


def pytest_addoption(parser):
parser.addoption("--foobar", action="store", dest="foobar_opt")


@pytest.mark.tryfirst
def pytest_load_initial_conftests(early_config):
opt = early_config.known_args_namespace.foobar_opt
print("--foobar=%s active! [%s]" % (opt, os.getpid()), file=sys.stderr)
6 changes: 6 additions & 0 deletions testing/foobar/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from setuptools import setup

setup(
py_modules=["foobarplugin"],
entry_points={"pytest11": ["foobarplugin = foobarplugin"]},
)
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ deps =
pytestlatest: pytest
pytestmaster: git+https://github.com/pytest-dev/pytest.git@master
pytestfeatures: git+https://github.com/pytest-dev/pytest.git@features
-etesting/foobar
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i understand the need for this hack, please add a comment linking this fun hack with the test id

commands=
pytest {posargs}

Expand Down