test_doxygen_timeout.py¶
tests/test_doxygen_timeout.py
The doxygen timeout must be reachable while the child is still alive.
test_the_doxygen_timeout_fires_while_the_child_lives
None test_doxygen_timeout.test_the_doxygen_timeout_fires_while_the_child_lives(Path tmp_path, pytest.MonkeyPatch monkeypatch, bool close_fds)
The watchdog bounds a live child.
tests/test_doxygen_timeout.py:110
Checks
assert not thread.is_alive(), (f"run_doxygen was still running after {elapsed:.0f} s against a " f"{_INNER_TIMEOUT} s timeout — the bound is unreachable, which is the whole defect: " "the blocking read of the child's output sits upstream of the wait that carries it" )assert isinstance(box.get("exc"), SystemExit), (f"expected the timeout path to exit; got {box.get('exc')!r}" )
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CLI-002 | inferred | test_the_doxygen_timeout_fires_while_the_child_lives → run_doxygen → doxygen_supports_sqlite3 |
| REQ-DDB-INDEX-001 | measured | test_the_doxygen_timeout_fires_while_the_child_lives → run_doxygen |
| REQ-DDB-PIPE-003 | measured | test_the_doxygen_timeout_fires_while_the_child_lives → run_doxygen → _build_doxyfile_content → extra_input_clears_exclude |
| REQ-DDB-PIPE-006 | measured | test_the_doxygen_timeout_fires_while_the_child_lives → run_doxygen → clean_subprocess_env |
Source · 43 lines
def test_the_doxygen_timeout_fires_while_the_child_lives(
tmp_path: Path, monkeypatch: pytest.MonkeyPatch, close_fds: bool
) -> None:
"""`pipe-held-open` IS THE REGRESSION CASE and it failed before the watchdog: the call was
still running at 20 s against a 3 s bound, because the blocking read sat upstream of the
timeout. `fds-closed` passed even then, which is exactly why both are here — one of them
alone would have called this fixed.
`SystemExit` is the pass condition, not an accident: `run_doxygen` reports the timeout and
exits non-zero, and asserting the EXIT distinguishes "the watchdog fired" from "the stub
happened to end".
@brief The watchdog bounds a live child.
@version 1
"""
stub_dir = _write_stub(tmp_path, close_fds)
monkeypatch.setenv("PATH", f"{stub_dir}{os.pathsep}{os.environ['PATH']}")
monkeypatch.setattr(doxygen, "_DOXYGEN_TIMEOUT", _INNER_TIMEOUT)
box: dict[str, BaseException] = {}
def _call() -> None:
try:
doxygen.run_doxygen(tmp_path / "Doxyfile", tmp_path, output_dir=tmp_path / "out")
except BaseException as exc: # SystemExit is the expected outcome
box["exc"] = exc
thread = threading.Thread(target=_call, daemon=True)
started = time.monotonic()
thread.start()
try:
thread.join(timeout=_OUTER_DEADLINE)
elapsed = time.monotonic() - started
assert not thread.is_alive(), (
f"run_doxygen was still running after {elapsed:.0f} s against a "
f"{_INNER_TIMEOUT} s timeout — the bound is unreachable, which is the whole defect: "
"the blocking read of the child's output sits upstream of the wait that carries it"
)
assert isinstance(box.get("exc"), SystemExit), (
f"expected the timeout path to exit; got {box.get('exc')!r}"
)
finally:
_reap()1 more lines, not shown