Skip to content

Commit

Permalink
Fix regression with custom arguments being dropped in non-local… (pyt…
Browse files Browse the repository at this point in the history
…est-dev#491)

* No idea what I'm doing.

* Extend integration test to cover ac3f6a7.

* Remove useless output to stop failing other tests.

* Reformat.

* Upgrade virtualenv to see if it fixes py34 builds

* Add CHANGELOG entry

* Make foobarplugin part of the test only

* Fix language_version in pre-commit for rst

* Fix test in Python 2

Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
  • Loading branch information
ionelmc and nicoddemus committed Dec 20, 2019
1 parent 66e74c8 commit 038a59e
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ environment:
- TOXENV: "py38-pytestfeatures"

install:
- C:\Python38\python -m pip install -U pip setuptools
- C:\Python38\python -m pip install -U pip setuptools virtualenv
- C:\Python38\python -m pip install -U tox setuptools_scm

build: false # Not a C# project, build stuff at the test step instead.
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ repos:
files: ^(CHANGELOG.rst|HOWTORELEASE.rst|README.rst|changelog/.*)$
language: python
additional_dependencies: [pygments, restructuredtext_lint]
python_version: python3.7
language_version: python3.7
File renamed without changes.
1 change: 1 addition & 0 deletions changelog/491.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix regression that caused custom plugin command-line arguments to be discarded when using ``--tx`` mode.
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
35 changes: 33 additions & 2 deletions testing/acceptance_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,46 @@ def test_crash():
)
assert result.ret == 1

def test_distribution_rsyncdirs_example(self, testdir):
def test_distribution_rsyncdirs_example(self, testdir, monkeypatch):
# use a custom plugin that has a custom command-line option to ensure
# this is propagated to workers (see #491)
testdir.makepyfile(
**{
"myplugin/src/foobarplugin.py": """
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)
"""
}
)
assert (testdir.tmpdir / "myplugin/src/foobarplugin.py").check(file=1)
monkeypatch.setenv(
"PYTHONPATH", str(testdir.tmpdir / "myplugin/src"), prepend=os.pathsep
)

source = testdir.mkdir("source")
dest = testdir.mkdir("dest")
subdir = source.mkdir("example_pkg")
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",
"-pfoobarplugin",
"--foobar=123",
"--dist=load",
"--rsyncdir=%(subdir)s" % locals(),
"--tx=popen//chdir=%(dest)s" % locals(),
p,
Expand All @@ -209,6 +239,7 @@ def test_distribution_rsyncdirs_example(self, testdir):
"*1 passed*",
]
)
result.stderr.fnmatch_lines(["--foobar=123 active! *"])
assert dest.join(subdir.basename).check(dir=1)

def test_backward_compatibility_worker_terminology(self, testdir):
Expand Down

0 comments on commit 038a59e

Please sign in to comment.