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

Remove boxed and provide --boxed via pytest-forked #1

Merged
merged 8 commits into from
Aug 5, 2017
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ test execution modes:
those for a combined test run. This allows to speed up
development or to use special resources of `remote machines`_.

* ``--boxed``: (not available on Windows) run each test in a boxed_
subprocess to survive ``SEGFAULTS`` or otherwise dying processes

* ``--looponfail``: run your tests repeatedly in a subprocess. After each run
py.test waits until a file in your project changes and then re-runs
Expand Down
1 change: 1 addition & 0 deletions changelog/1.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
remove the implementation of "boxed" and use pytest-forked for providing ``--boxed``
Copy link
Member

Choose a reason for hiding this comment

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

``--boxed`` functionality has been moved to a separate plugin, `pytest-forked <https://github.com/pytest-dev/pytest-forked>`_. This release now depends on `` pytest-forked`` and provides ``--boxed`` as a backward compatibility option.

12 changes: 6 additions & 6 deletions example/boxed.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ to run each test in a controlled subprocess. Here is a basic example::
@pytest.mark.parametrize("arg", range(50))
def test_func(arg):
time.sleep(0.05) # each tests takes a while
if arg % 19 == 0:
if arg % 19 == 0:
Copy link
Member

Choose a reason for hiding this comment

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

I think we should add to the top of this file:

.. note::

  Since 2.0, the actual implementation of the ``--boxed`` option has been moved to a 
  separate plugin, `pytest-forked <https://github.com/pytest-dev/pytest-forked>`_ 
  which can be installed independently. The ``--boxed`` command-line options remains 
  for backward compatibility reasons.

os.kill(os.getpid(), 15)

If you run this with::

$ py.test --boxed
$ py.test -n1
=========================== test session starts ============================
platform linux2 -- Python 2.7.3 -- pytest-2.3.0.dev8
plugins: xdist, bugzilla, cache, oejskit, cli, pep8, cov
collecting ... collected 50 items

test_module.py f..................f..................f...........

================================= FAILURES =================================
_______________________________ test_func[0] _______________________________
/home/hpk/tmp/doc-exec-420/test_module.py:6: running the test CRASHED with signal 15
Expand All @@ -40,13 +40,13 @@ You'll see that a couple of tests are reported as crashing, indicated
by lower-case ``f`` and the respective failure summary. You can also use
the xdist-provided parallelization feature to speed up your testing::

$ py.test --boxed -n3
$ py.test -n3
=========================== test session starts ============================
platform linux2 -- Python 2.7.3 -- pytest-2.3.0.dev8
plugins: xdist, bugzilla, cache, oejskit, cli, pep8, cov
gw0 I / gw1 I / gw2 I
gw0 [50] / gw1 [50] / gw2 [50]

scheduling tests via LoadScheduling
..f...............f..................f............
================================= FAILURES =================================
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from setuptools import setup, find_packages

install_requires = ['execnet>=1.1', 'pytest>=3.0.0']
install_requires = ['execnet>=1.1', 'pytest>=3.0.0', 'pytest-forked']

if version_info < (2, 7):
install_requires.append('ordereddict')
Expand All @@ -24,7 +24,6 @@
'pytest11': [
'xdist = xdist.plugin',
'xdist.looponfail = xdist.looponfail',
'xdist.boxed = xdist.boxed',
],
},
zip_safe=False,
Expand Down
58 changes: 0 additions & 58 deletions testing/test_boxed.py

This file was deleted.

60 changes: 0 additions & 60 deletions xdist/boxed.py

This file was deleted.

12 changes: 9 additions & 3 deletions xdist/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ def pytest_addoption(parser):
help="shortcut for '--dist=load --tx=NUM*popen', "
"you can use 'auto' here for auto detection CPUs number on "
"host system")
group._addoption('--max-slave-restart', action="store", default=None,
group.addoption('--max-slave-restart', action="store", default=None,
help="maximum number of slaves that can be restarted "
"when crashed (set to zero to disable this feature)")
group._addoption(
group.addoption(
'--dist', metavar="distmode",
action="store", choices=['each', 'load', 'loadscope', 'no'],
dest="dist", default="no",
Expand All @@ -40,7 +40,7 @@ def pytest_addoption(parser):
"loadscope: load balance by sending pending groups of tests in"
" the same scope to any available environment.\n\n"
"(default) no: run tests inprocess, don't distribute."))
group._addoption(
group.addoption(
'--tx', dest="tx", action="append", default=[],
metavar="xspec",
help=("add a test execution environment. some examples: "
Expand All @@ -57,6 +57,9 @@ def pytest_addoption(parser):
'--rsyncignore', action="append", default=[], metavar="GLOB",
help="add expression for ignores when rsyncing to remote tx nodes.")

group.addoption(
"--boxed", action="store_true",
help="backward compatibility alias for pytest-forked --forked")
parser.addini(
'rsyncdirs', 'list of (relative) paths to be rsynced for'
' remote distributed testing.', type="pathlist")
Expand All @@ -67,6 +70,7 @@ def pytest_addoption(parser):
"looponfailroots", type="pathlist",
help="directories to check for changes", default=[py.path.local()])


# -------------------------------------------------------------------------
# distributed testing hooks
# -------------------------------------------------------------------------
Expand All @@ -93,6 +97,8 @@ def pytest_configure(config):
config.pluginmanager.register(session, "dsession")
tr = config.pluginmanager.getplugin("terminalreporter")
tr.showfspath = False
if config.getoption("boxed"):
config.option.forked = True


@pytest.mark.tryfirst
Expand Down