From ad3e45590f6d9460945caf74819ed8e7b4d06897 Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Tue, 1 Sep 2015 23:10:47 +0200 Subject: [PATCH] remove the boxed plugin code --- setup.py | 1 - testing/test_boxed.py | 58 ----------------------------------------- xdist/boxed.py | 60 ------------------------------------------- 3 files changed, 119 deletions(-) delete mode 100644 testing/test_boxed.py delete mode 100644 xdist/boxed.py diff --git a/setup.py b/setup.py index 64bb5f2..9876aeb 100644 --- a/setup.py +++ b/setup.py @@ -24,7 +24,6 @@ setup( 'pytest11': [ 'xdist = xdist.plugin', 'xdist.looponfail = xdist.looponfail', - 'xdist.boxed = xdist.boxed', ], }, zip_safe=False, diff --git a/testing/test_boxed.py b/testing/test_boxed.py deleted file mode 100644 index d624a95..0000000 --- a/testing/test_boxed.py +++ /dev/null @@ -1,58 +0,0 @@ -import pytest -import os - -needsfork = pytest.mark.skipif(not hasattr(os, "fork"), - reason="os.fork required") - - -@needsfork -def test_functional_boxed(testdir): - p1 = testdir.makepyfile(""" - import os - def test_function(): - os.kill(os.getpid(), 15) - """) - result = testdir.runpytest(p1, "--boxed") - result.stdout.fnmatch_lines([ - "*CRASHED*", - "*1 failed*" - ]) - - -@needsfork -@pytest.mark.parametrize("capmode", [ - "no", - pytest.mark.xfail("sys", reason="capture cleanup needed"), - pytest.mark.xfail("fd", reason="capture cleanup needed")]) -def test_functional_boxed_capturing(testdir, capmode): - p1 = testdir.makepyfile(""" - import os - import sys - def test_function(): - sys.stdout.write("hello\\n") - sys.stderr.write("world\\n") - os.kill(os.getpid(), 15) - """) - result = testdir.runpytest(p1, "--boxed", "--capture=%s" % capmode) - result.stdout.fnmatch_lines(""" - *CRASHED* - *stdout* - hello - *stderr* - world - *1 failed* - """) - - -class TestOptionEffects: - def test_boxed_option_default(self, testdir): - tmpdir = testdir.tmpdir.ensure("subdir", dir=1) - config = testdir.parseconfig() - assert not config.option.boxed - pytest.importorskip("execnet") - config = testdir.parseconfig('-d', tmpdir) - assert not config.option.boxed - - def test_is_not_boxed_by_default(self, testdir): - config = testdir.parseconfig(testdir.tmpdir) - assert not config.option.boxed diff --git a/xdist/boxed.py b/xdist/boxed.py deleted file mode 100644 index 009a112..0000000 --- a/xdist/boxed.py +++ /dev/null @@ -1,60 +0,0 @@ - -import py - - -def pytest_addoption(parser): - group = parser.getgroup("xdist", "distributed and subprocess testing") - group.addoption( - '--boxed', - action="store_true", dest="boxed", default=False, - help="box each test run in a separate process (unix)") - - -def pytest_runtest_protocol(item): - if item.config.getvalue("boxed"): - reports = forked_run_report(item) - for rep in reports: - item.ihook.pytest_runtest_logreport(report=rep) - return True - - -def forked_run_report(item): - # for now, we run setup/teardown in the subprocess - # XXX optionally allow sharing of setup/teardown - from _pytest.runner import runtestprotocol - EXITSTATUS_TESTEXIT = 4 - import marshal - from xdist.remote import serialize_report - from xdist.slavemanage import unserialize_report - - def runforked(): - try: - reports = runtestprotocol(item, log=False) - except KeyboardInterrupt: - py.std.os._exit(EXITSTATUS_TESTEXIT) - return marshal.dumps([serialize_report(x) for x in reports]) - - ff = py.process.ForkedFunc(runforked) - result = ff.waitfinish() - if result.retval is not None: - report_dumps = marshal.loads(result.retval) - return [unserialize_report("testreport", x) for x in report_dumps] - else: - if result.exitstatus == EXITSTATUS_TESTEXIT: - py.test.exit("forked test item %s raised Exit" % (item,)) - return [report_process_crash(item, result)] - - -def report_process_crash(item, result): - path, lineno = item._getfslineno() - info = ("%s:%s: running the test CRASHED with signal %d" % - (path, lineno, result.signal)) - from _pytest import runner - call = runner.CallInfo(lambda: 0/0, "???") - call.excinfo = info - rep = runner.pytest_runtest_makereport(item, call) - if result.out: - rep.sections.append(("captured stdout", result.out)) - if result.err: - rep.sections.append(("captured stderr", result.err)) - return rep