mirror of
https://github.com/elder-plinius/OBLITERATUS.git
synced 2026-08-18 00:47:23 +02:00
test: enforce Wave A quality lock
This commit is contained in:
@@ -43,6 +43,11 @@ def test_repeat_gate_records_each_pass(monkeypatch, tmp_path):
|
||||
return SimpleNamespace(returncode=0, stdout="2 passed\n", stderr="")
|
||||
|
||||
monkeypatch.setattr(run_repeat_gate.subprocess, "run", fake_run)
|
||||
monkeypatch.setattr(
|
||||
run_repeat_gate,
|
||||
"junit_snapshot",
|
||||
lambda _path: {"tests": 2, "failed_nodeids": [], "skipped_nodeids": []},
|
||||
)
|
||||
output = tmp_path / "repeat.json"
|
||||
assert run_repeat_gate.run_repeat_gate(
|
||||
["first.py", "second.py"], output=output, python="python-fixture",
|
||||
@@ -53,18 +58,61 @@ def test_repeat_gate_records_each_pass(monkeypatch, tmp_path):
|
||||
"0", "1", "8675309",
|
||||
]
|
||||
assert calls[0][0] == [
|
||||
"python-fixture", "-m", "pytest", "--no-cov", "-q", "first.py", "second.py",
|
||||
"python-fixture",
|
||||
"-m",
|
||||
"pytest",
|
||||
"--no-cov",
|
||||
"-q",
|
||||
f"--junitxml={tmp_path / 'repeat-pass-1.xml'}",
|
||||
"first.py",
|
||||
"second.py",
|
||||
]
|
||||
|
||||
|
||||
def test_repeat_gate_stops_and_preserves_failure_output(monkeypatch, tmp_path):
|
||||
def test_repeat_gate_completes_all_passes_and_preserves_failure_output(monkeypatch, tmp_path):
|
||||
def fake_run(*_args, **_kwargs):
|
||||
return SimpleNamespace(returncode=3, stdout="failed output", stderr="failure detail")
|
||||
|
||||
monkeypatch.setattr(run_repeat_gate.subprocess, "run", fake_run)
|
||||
monkeypatch.setattr(
|
||||
run_repeat_gate,
|
||||
"junit_snapshot",
|
||||
lambda _path: {
|
||||
"tests": 1,
|
||||
"failed_nodeids": ["tests.test_example::test_failure"],
|
||||
"skipped_nodeids": [],
|
||||
},
|
||||
)
|
||||
output = tmp_path / "repeat.json"
|
||||
assert run_repeat_gate.run_repeat_gate(["test.py"], output=output) == 3
|
||||
evidence = json.loads(output.read_text())
|
||||
assert evidence["status"] == "failed"
|
||||
assert len(evidence["passes"]) == 1
|
||||
assert len(evidence["passes"]) == 3
|
||||
assert evidence["passes"][0]["stderr"] == "failure detail"
|
||||
assert evidence["consistent_failures"] == [{
|
||||
"nodeid": "tests.test_example::test_failure",
|
||||
"occurrences": 3,
|
||||
}]
|
||||
|
||||
|
||||
def test_repeat_gate_identifies_intermittent_failures(monkeypatch, tmp_path):
|
||||
results = iter([
|
||||
SimpleNamespace(returncode=1, stdout="failed", stderr=""),
|
||||
SimpleNamespace(returncode=0, stdout="passed", stderr=""),
|
||||
SimpleNamespace(returncode=1, stdout="failed", stderr=""),
|
||||
])
|
||||
snapshots = iter([
|
||||
{"tests": 1, "failed_nodeids": ["tests.test_example::test_flake"], "skipped_nodeids": []},
|
||||
{"tests": 1, "failed_nodeids": [], "skipped_nodeids": []},
|
||||
{"tests": 1, "failed_nodeids": ["tests.test_example::test_flake"], "skipped_nodeids": []},
|
||||
])
|
||||
monkeypatch.setattr(run_repeat_gate.subprocess, "run", lambda *_args, **_kwargs: next(results))
|
||||
monkeypatch.setattr(run_repeat_gate, "junit_snapshot", lambda _path: next(snapshots))
|
||||
|
||||
output = tmp_path / "repeat.json"
|
||||
assert run_repeat_gate.run_repeat_gate(["test.py"], output=output) == 1
|
||||
evidence = json.loads(output.read_text())
|
||||
assert evidence["flake_candidates"] == [{
|
||||
"nodeid": "tests.test_example::test_flake",
|
||||
"occurrences": 2,
|
||||
}]
|
||||
|
||||
Reference in New Issue
Block a user