Skip to content

Commit 038a59e

Browse files
ionelmcnicoddemus
andcommitted
Fix regression with custom arguments being dropped in non-local… (#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 <[email protected]>
1 parent 66e74c8 commit 038a59e

File tree

6 files changed

+37
-4
lines changed

6 files changed

+37
-4
lines changed

.appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ environment:
1010
- TOXENV: "py38-pytestfeatures"
1111

1212
install:
13-
- C:\Python38\python -m pip install -U pip setuptools
13+
- C:\Python38\python -m pip install -U pip setuptools virtualenv
1414
- C:\Python38\python -m pip install -U tox setuptools_scm
1515

1616
build: false # Not a C# project, build stuff at the test step instead.

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ repos:
2121
files: ^(CHANGELOG.rst|HOWTORELEASE.rst|README.rst|changelog/.*)$
2222
language: python
2323
additional_dependencies: [pygments, restructuredtext_lint]
24-
python_version: python3.7
24+
language_version: python3.7
File renamed without changes.

changelog/491.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix regression that caused custom plugin command-line arguments to be discarded when using ``--tx`` mode.

src/xdist/workermanage.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ def make_reltoroot(roots, args):
190190
parts = arg.split(splitcode)
191191
fspath = py.path.local(parts[0])
192192
if not fspath.exists():
193+
result.append(arg)
193194
continue
194195
for root in roots:
195196
x = fspath.relto(root)

testing/acceptance_test.py

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,16 +186,46 @@ def test_crash():
186186
)
187187
assert result.ret == 1
188188

189-
def test_distribution_rsyncdirs_example(self, testdir):
189+
def test_distribution_rsyncdirs_example(self, testdir, monkeypatch):
190+
# use a custom plugin that has a custom command-line option to ensure
191+
# this is propagated to workers (see #491)
192+
testdir.makepyfile(
193+
**{
194+
"myplugin/src/foobarplugin.py": """
195+
from __future__ import print_function
196+
197+
import os
198+
import sys
199+
import pytest
200+
201+
def pytest_addoption(parser):
202+
parser.addoption("--foobar", action="store", dest="foobar_opt")
203+
204+
@pytest.mark.tryfirst
205+
def pytest_load_initial_conftests(early_config):
206+
opt = early_config.known_args_namespace.foobar_opt
207+
print("--foobar=%s active! [%s]" % (opt, os.getpid()), file=sys.stderr)
208+
"""
209+
}
210+
)
211+
assert (testdir.tmpdir / "myplugin/src/foobarplugin.py").check(file=1)
212+
monkeypatch.setenv(
213+
"PYTHONPATH", str(testdir.tmpdir / "myplugin/src"), prepend=os.pathsep
214+
)
215+
190216
source = testdir.mkdir("source")
191217
dest = testdir.mkdir("dest")
192218
subdir = source.mkdir("example_pkg")
193219
subdir.ensure("__init__.py")
194220
p = subdir.join("test_one.py")
195221
p.write("def test_5():\n assert not __file__.startswith(%r)" % str(p))
196-
result = testdir.runpytest(
222+
result = testdir.runpytest_subprocess(
197223
"-v",
198224
"-d",
225+
"-s",
226+
"-pfoobarplugin",
227+
"--foobar=123",
228+
"--dist=load",
199229
"--rsyncdir=%(subdir)s" % locals(),
200230
"--tx=popen//chdir=%(dest)s" % locals(),
201231
p,
@@ -209,6 +239,7 @@ def test_distribution_rsyncdirs_example(self, testdir):
209239
"*1 passed*",
210240
]
211241
)
242+
result.stderr.fnmatch_lines(["--foobar=123 active! *"])
212243
assert dest.join(subdir.basename).check(dir=1)
213244

214245
def test_backward_compatibility_worker_terminology(self, testdir):

0 commit comments

Comments
 (0)