From ac3f6a78c7401aba9b62c2c67f280a129ae84eaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionel=20Cristian=20M=C4=83rie=C8=99?= Date: Sat, 7 Dec 2019 19:00:05 +0200 Subject: [PATCH 1/9] No idea what I'm doing. --- src/xdist/workermanage.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/xdist/workermanage.py b/src/xdist/workermanage.py index d95b481d..5f30edf2 100644 --- a/src/xdist/workermanage.py +++ b/src/xdist/workermanage.py @@ -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) From 0f1e81c4d55f824581ac3929b997b34d6e7605e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionel=20Cristian=20M=C4=83rie=C8=99?= Date: Mon, 9 Dec 2019 12:37:49 +0200 Subject: [PATCH 2/9] Extend integration test to cover ac3f6a78c7401aba9b62c2c67f280a129ae84eaf. --- testing/acceptance_test.py | 12 +++++++++++- testing/foobar/foobarplugin.py | 17 +++++++++++++++++ testing/foobar/setup.py | 9 +++++++++ tox.ini | 1 + 4 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 testing/foobar/foobarplugin.py create mode 100644 testing/foobar/setup.py diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index 4537fd0b..ae2af01a 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -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, @@ -203,12 +206,19 @@ def test_distribution_rsyncdirs_example(self, testdir): assert result.ret == 0 result.stdout.fnmatch_lines( [ + "adding --foobar option. *", "*0* *cwd*", # "RSyncStart: [G1]", # "RSyncFinished: [G1]", "*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): diff --git a/testing/foobar/foobarplugin.py b/testing/foobar/foobarplugin.py new file mode 100644 index 00000000..724aea1d --- /dev/null +++ b/testing/foobar/foobarplugin.py @@ -0,0 +1,17 @@ +from __future__ import print_function + +import os +import sys + +import pytest + + +def pytest_addoption(parser): + print("adding --foobar option. [%s]" % os.getpid()) + 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) diff --git a/testing/foobar/setup.py b/testing/foobar/setup.py new file mode 100644 index 00000000..ced1d15d --- /dev/null +++ b/testing/foobar/setup.py @@ -0,0 +1,9 @@ +from setuptools import setup +setup( + py_modules=['foobarplugin'], + entry_points={ + 'pytest11': [ + 'foobarplugin = foobarplugin', + ], + }, +) diff --git a/tox.ini b/tox.ini index 3a52a954..cdcbe9ac 100644 --- a/tox.ini +++ b/tox.ini @@ -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 commands= pytest {posargs} From a71730bcf43bc11367ca2654780f804182ac5a29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionel=20Cristian=20M=C4=83rie=C8=99?= Date: Mon, 9 Dec 2019 12:55:47 +0200 Subject: [PATCH 3/9] Remove useless output to stop failing other tests. --- testing/acceptance_test.py | 1 - testing/foobar/foobarplugin.py | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index ae2af01a..6ebcd0dc 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -206,7 +206,6 @@ def test_distribution_rsyncdirs_example(self, testdir): assert result.ret == 0 result.stdout.fnmatch_lines( [ - "adding --foobar option. *", "*0* *cwd*", # "RSyncStart: [G1]", # "RSyncFinished: [G1]", diff --git a/testing/foobar/foobarplugin.py b/testing/foobar/foobarplugin.py index 724aea1d..2bb45921 100644 --- a/testing/foobar/foobarplugin.py +++ b/testing/foobar/foobarplugin.py @@ -7,8 +7,7 @@ def pytest_addoption(parser): - print("adding --foobar option. [%s]" % os.getpid()) - parser.addoption("--foobar", action='store', dest='foobar_opt') + parser.addoption("--foobar", action="store", dest="foobar_opt") @pytest.mark.tryfirst From 3a861971e18dcb15aab1966709665c3ed74e3986 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionel=20Cristian=20M=C4=83rie=C8=99?= Date: Mon, 9 Dec 2019 12:55:58 +0200 Subject: [PATCH 4/9] Reformat. --- testing/acceptance_test.py | 5 +---- testing/foobar/setup.py | 9 +++------ 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index 6ebcd0dc..c40c6e85 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -213,10 +213,7 @@ def test_distribution_rsyncdirs_example(self, testdir): ] ) result.stderr.fnmatch_lines( - [ - "--foobar=123 active! *", - "--foobar=123 active! *", - ] + ["--foobar=123 active! *", "--foobar=123 active! *"] ) assert dest.join(subdir.basename).check(dir=1) diff --git a/testing/foobar/setup.py b/testing/foobar/setup.py index ced1d15d..0a8f5d1b 100644 --- a/testing/foobar/setup.py +++ b/testing/foobar/setup.py @@ -1,9 +1,6 @@ from setuptools import setup + setup( - py_modules=['foobarplugin'], - entry_points={ - 'pytest11': [ - 'foobarplugin = foobarplugin', - ], - }, + py_modules=["foobarplugin"], + entry_points={"pytest11": ["foobarplugin = foobarplugin"]}, ) From fd9b278f2f5dc609116583a787ca914cfab8fd41 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Fri, 13 Dec 2019 10:23:23 -0300 Subject: [PATCH 5/9] Upgrade virtualenv to see if it fixes py34 builds --- .appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.appveyor.yml b/.appveyor.yml index ea522dcb..8ece1688 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -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. From fd63aa39752a3dc21068766eb874539aa208bf44 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Thu, 19 Dec 2019 19:59:50 -0300 Subject: [PATCH 6/9] Add CHANGELOG entry --- changelog/{486.feature => 486.feature.rst} | 0 changelog/491.bugfix.rst | 1 + 2 files changed, 1 insertion(+) rename changelog/{486.feature => 486.feature.rst} (100%) create mode 100644 changelog/491.bugfix.rst diff --git a/changelog/486.feature b/changelog/486.feature.rst similarity index 100% rename from changelog/486.feature rename to changelog/486.feature.rst diff --git a/changelog/491.bugfix.rst b/changelog/491.bugfix.rst new file mode 100644 index 00000000..4f704239 --- /dev/null +++ b/changelog/491.bugfix.rst @@ -0,0 +1 @@ +Fix regression that caused custom plugin command-line arguments to be discarded when using ``--tx`` mode. From abb33ab9236ae5419b35abf004121d0e054db90d Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Thu, 19 Dec 2019 20:27:06 -0300 Subject: [PATCH 7/9] Make foobarplugin part of the test only --- testing/acceptance_test.py | 29 ++++++++++++++++++++++++++++- testing/foobar/foobarplugin.py | 16 ---------------- testing/foobar/setup.py | 6 ------ tox.ini | 1 - 4 files changed, 28 insertions(+), 24 deletions(-) delete mode 100644 testing/foobar/foobarplugin.py delete mode 100644 testing/foobar/setup.py diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index c40c6e85..63869b08 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -186,7 +186,33 @@ 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") @@ -197,6 +223,7 @@ def test_distribution_rsyncdirs_example(self, testdir): "-v", "-d", "-s", + "-pfoobarplugin", "--foobar=123", "--dist=load", "--rsyncdir=%(subdir)s" % locals(), diff --git a/testing/foobar/foobarplugin.py b/testing/foobar/foobarplugin.py deleted file mode 100644 index 2bb45921..00000000 --- a/testing/foobar/foobarplugin.py +++ /dev/null @@ -1,16 +0,0 @@ -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) diff --git a/testing/foobar/setup.py b/testing/foobar/setup.py deleted file mode 100644 index 0a8f5d1b..00000000 --- a/testing/foobar/setup.py +++ /dev/null @@ -1,6 +0,0 @@ -from setuptools import setup - -setup( - py_modules=["foobarplugin"], - entry_points={"pytest11": ["foobarplugin = foobarplugin"]}, -) diff --git a/tox.ini b/tox.ini index cdcbe9ac..3a52a954 100644 --- a/tox.ini +++ b/tox.ini @@ -11,7 +11,6 @@ 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 commands= pytest {posargs} From d2184434b2fe59b41630386740c4277d77645545 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Thu, 19 Dec 2019 20:29:09 -0300 Subject: [PATCH 8/9] Fix language_version in pre-commit for rst --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 04f86d5b..9bd71da1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 From 665bb5f47d7cf37d44fcd1148b2c3e55d6865214 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Thu, 19 Dec 2019 20:45:57 -0300 Subject: [PATCH 9/9] Fix test in Python 2 --- testing/acceptance_test.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index 63869b08..d93f08ed 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -239,9 +239,7 @@ def pytest_load_initial_conftests(early_config): "*1 passed*", ] ) - result.stderr.fnmatch_lines( - ["--foobar=123 active! *", "--foobar=123 active! *"] - ) + result.stderr.fnmatch_lines(["--foobar=123 active! *"]) assert dest.join(subdir.basename).check(dir=1) def test_backward_compatibility_worker_terminology(self, testdir):