Terminate the test loop if shouldfail or shouldstop is set (#1026)
This commit is contained in:
@@ -109,12 +109,12 @@ class TestDistribution:
|
||||
)
|
||||
assert result.ret == 1
|
||||
|
||||
def test_exitfail_waits_for_workers_to_finish(
|
||||
def test_exitfirst_waits_for_workers_to_finish(
|
||||
self, pytester: pytest.Pytester
|
||||
) -> None:
|
||||
"""The DSession waits for workers before exiting early on failure.
|
||||
|
||||
When -x/--exitfail is set, the DSession wait for the workers to finish
|
||||
When -x/--exitfirst is set, the DSession wait for all workers to finish
|
||||
before raising an Interrupt exception. This prevents reports from the
|
||||
faiing test and other tests from being discarded.
|
||||
"""
|
||||
@@ -138,15 +138,14 @@ class TestDistribution:
|
||||
time.sleep(0.3)
|
||||
"""
|
||||
)
|
||||
# Two workers are used
|
||||
result = pytester.runpytest(p1, "-x", "-rA", "-v", "-n2")
|
||||
assert result.ret == 2
|
||||
result.stdout.re_match_lines([".*Interrupted: stopping.*[12].*"])
|
||||
m = re.search(r"== (\d+) failed, (\d+) passed in ", str(result.stdout))
|
||||
assert m
|
||||
n_failed, n_passed = (int(s) for s in m.groups())
|
||||
assert 1 <= n_failed <= 2
|
||||
assert 1 <= n_passed <= 3
|
||||
assert (n_passed + n_failed) < 6
|
||||
# DSession should stop when the first failure is reached. Two failures
|
||||
# may actually occur, due to timing.
|
||||
outcomes = result.parseoutcomes()
|
||||
assert "failed" in outcomes, "Expected at least one failure"
|
||||
assert 1 <= outcomes["failed"] <= 2, "Expected no more than 2 failures"
|
||||
|
||||
def test_basetemp_in_subprocesses(self, pytester: pytest.Pytester) -> None:
|
||||
p1 = pytester.makepyfile(
|
||||
@@ -1180,6 +1179,23 @@ def test_internal_error_with_maxfail(pytester: pytest.Pytester) -> None:
|
||||
assert "INTERNALERROR" not in result.stderr.str()
|
||||
|
||||
|
||||
def test_maxfail_causes_early_termination(pytester: pytest.Pytester) -> None:
|
||||
"""
|
||||
Ensure subsequent tests on a worker aren't run when using --maxfail (#1024).
|
||||
"""
|
||||
pytester.makepyfile(
|
||||
"""
|
||||
def test1():
|
||||
assert False
|
||||
|
||||
def test2():
|
||||
pass
|
||||
"""
|
||||
)
|
||||
result = pytester.runpytest_subprocess("--maxfail=1", "-n 1")
|
||||
result.assert_outcomes(failed=1)
|
||||
|
||||
|
||||
def test_internal_errors_propagate_to_controller(pytester: pytest.Pytester) -> None:
|
||||
pytester.makeconftest(
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user