test_print_next_stress.py python
99 lines 3.6 KB
Raw
sha256:c07f2f34a0db9f43fe866f157d1935322008545ff8940c06c7c921eb219c55ab NXP-b DONE: independent BV-r2 pass + ISR (SD-17) Human minor ⚠ breaking 1 day ago
1 """Stress — large handover + NXP path edge cases (§ONS.12 / §NXP.8)."""
2
3 from __future__ import annotations
4
5 import time
6 from pathlib import Path
7
8 from cli.kit_root import kit_root
9 from tests.support import git_status_runner, run_cli, write_config
10 from tools.print_next.extract import (
11 CURRENT_NEXT_HEADING,
12 CurrentNextResult,
13 extract_current_next,
14 format_current_next,
15 set_read_at_clock,
16 )
17
18 MARKER = "STRESS-FENCE-BODY-UNIQUE-TOKEN"
19 PERF_BOUND_S = 2.0
20 FIXED_READ_AT = "2026-09-04T12:00:00Z"
21
22
23 def test_stress_large_handover_fence_at_end(tmp_path: Path) -> None:
24 docs = tmp_path / "docs"
25 docs.mkdir(parents=True, exist_ok=True)
26 path = docs / "OVERSEER-HANDOVER.md"
27 done_rows = "\n".join(f"| **DONE-{i}** | Auto | **DONE** | filler |" for i in range(200))
28 filler = ("x" * 1024 + "\n") * (1550) # ≥1.5 MiB of padding before fence
29 body = (
30 f"# Handover\n\n## Queue\n\n{done_rows}\n\n{filler}\n"
31 f"### Paste-ready prompt — stress\n\n```text\n{MARKER}\nModel: Auto\n```\n"
32 )
33 path.write_text(body, encoding="utf-8")
34 assert path.stat().st_size >= int(1.5 * 1024 * 1024)
35
36 start = time.perf_counter()
37 result = extract_current_next(path, repo_relative_path="docs/OVERSEER-HANDOVER.md", lane=None)
38 elapsed = time.perf_counter() - start
39 assert isinstance(result, CurrentNextResult)
40 assert MARKER in result.fence
41 assert "Model: Auto" in result.fence
42 assert elapsed < PERF_BOUND_S
43
44
45 def test_stress_long_path_unicode_and_long_fence(tmp_path: Path, capsys) -> None:
46 """Deep nested root, unicode/spaces in path, long fence body, long repo name."""
47 nested = tmp_path / "deep" / "nest" / "with spaces" / "unicodé-repo"
48 nested.mkdir(parents=True)
49 write_config(nested, "config-git-only.yaml")
50 cfg = (nested / ".overseer" / "config.yaml").read_text(encoding="utf-8")
51 long_name = "x" * 80 + "-repo"
52 (nested / ".overseer" / "config.yaml").write_text(
53 cfg.replace("name: test-git", f"name: {long_name}"),
54 encoding="utf-8",
55 )
56 docs = nested / "docs"
57 docs.mkdir(parents=True, exist_ok=True)
58 long_body = ("LINE\n" * 500) + "Model: Auto\n"
59 (docs / "OVERSEER-HANDOVER.md").write_text(
60 f"# H\n\n### Paste-ready prompt\n\n```text\n{long_body}```\n",
61 encoding="utf-8",
62 )
63 (docs / "ROADMAP.md").write_text("# R\n", encoding="utf-8")
64 set_read_at_clock(lambda: FIXED_READ_AT)
65 try:
66 code = run_cli(["next"], cwd=nested, runner=git_status_runner(), kit=kit_root())
67 out = capsys.readouterr().out
68 assert code == 0
69 assert CURRENT_NEXT_HEADING in out
70 assert long_name in out
71 assert nested.resolve().as_posix() in out
72 assert out.count("LINE") >= 500
73 finally:
74 set_read_at_clock(None)
75
76
77 def test_stress_many_lanes_status_advisory(tmp_path: Path) -> None:
78 from adapters.config import load_config
79 from tools.workspace.board_names import status_board_name_advisory
80
81 write_config(tmp_path, "config-two-lane.yaml")
82 config = load_config(tmp_path / ".overseer" / "config.yaml")
83 # Two-lane fixture uses bare lane board names → one advisory naming count.
84 msg = status_board_name_advisory(config)
85 assert msg is not None
86 assert "2 lanes non-compliant" in msg
87 assert "first:" in msg
88
89
90 def test_stress_format_at_filesystem_root_path() -> None:
91 result = CurrentNextResult(path="docs/H.md", lane=None, fence="Model: Auto\n")
92 human = format_current_next(
93 result,
94 repo_name="r",
95 repo_root_abs="/",
96 read_at=FIXED_READ_AT,
97 )
98 assert "`/`" in human
99 assert human.startswith(CURRENT_NEXT_HEADING)
File History 1 commit
sha256:c07f2f34a0db9f43fe866f157d1935322008545ff8940c06c7c921eb219c55ab NXP-b DONE: independent BV-r2 pass + ISR (SD-17) Human minor 1 day ago