Add LSP-assisted terminal E2E coverage

This commit is contained in:
slhx agent
2026-06-21 19:27:49 +02:00
parent d6ebf1cc06
commit 38c487f7c3
3 changed files with 48 additions and 5 deletions
+3
View File
@@ -31,6 +31,9 @@ Artifact roles:
while still recording all raw bytes sent.
- `saved-files.tsv`: per-file hashes/byte counts for scenarios that assert more
than the launched file, such as multi-file coding workflows.
- `e2e-prelude.trace` (scenario temp dir only when needed): harness-only trace
lines consumed before raw-mode input to seed deterministic provider fixtures;
this is not a runtime config surface.
- `raw.bin`: exact PTY bytes for low-level debugging.
Golden policy:
+21 -1
View File
@@ -45,6 +45,7 @@ class Scenario:
required_attrs: tuple[str, ...] = ("cursor", "status", "current-line")
max_key_events: int | None = None
expect_files: tuple[tuple[str, str], ...] = ()
prelude: str = ""
def visible_controls(data: bytes) -> str:
@@ -456,10 +457,23 @@ def setup_multifile(tmp: Path) -> tuple[Path, str | None]:
return beta, "beta\n"
def setup_lsp_assist(tmp: Path) -> tuple[Path, str | None]:
target = tmp / "lsp.zig"
target.write_text("abc\n", encoding="utf-8")
return target, "abc\n"
MOBILE_SYMBOL_SAVE_QUIT = tuple(bytes([b]) for b in b" ps w q")
MOBILE_REPLACE_SAVE_QUIT = tuple(bytes([b]) for b in b"rx w q")
ATTACHED_SAVE_QUIT = (b"i", b"\x1b[F", b"!", b"\x1b", b" ", b"w", b" ", b"q")
PANEL_QUIT = (b" ", b"q")
LSP_ASSIST_PRELUDE = "\n".join((
"lsp_hover_fixture zls|add(lhs, rhs)|Very long documentation that should stay viewport safe.",
"lsp_signature_fixture zls|add(lhs: i32, rhs: i32) active=rhs",
"diagnostic_fixture zls|1|lsp.zig|0|3|warning|demo",
"language_default_format zls",
"language_edit zls|format|1|0|3|ZLS",
))
IOS_DEFAULT_KEYS = set(b"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ")
@@ -478,6 +492,7 @@ SCENARIOS = [
Scenario("percent-match-jump", 56, 12, "brackets", "attached-keyboard", "match-jump", "truecolor", "file", setup_brackets, (b"%", b"i", b"X", b"\x1b", b" ", b"w", b" ", b"q"), "(abX)", ("1│", "")),
Scenario("select-mode-colors", 56, 12, "short", "attached-keyboard", "select", "truecolor", "file", setup_short, (b"s", b"w", b"n", b" ", b"q"), "abcdef\n", ("attr:selection", "", "mode:normal")),
Scenario("multi-file-coding-loop", 72, 16, "repo-multifile", "attached-keyboard", "multi-file", "truecolor", "file", setup_multifile, (b"A", b"?", b"\x1b", b" ", b"w", b" ", b"o", b"r", b"e", b"p", b"o", b"/", b"a", b"l", b"p", b"h", b"a", b".", b"z", b"i", b"g", b"\r", b"A", b"!", b"\x1b", b" ", b"w", b" ", b"q"), None, ("alpha.zig", "beta", "", "mode:normal"), max_key_events=30, expect_files=(("alpha.zig", "alpha!\n"), ("beta.zig", "beta?"))),
Scenario("lsp-assisted-coding", 60, 12, "lsp-fixture", "attached-keyboard", "lsp", "truecolor", "file", setup_lsp_assist, (b" ", b"l", b"h", b" ", b"l", b"s", b" ", b"d", b"q", b" ", b"d", b"n", b" ", b"l", b"f", b" ", b"Q"), "abc\n", ("[zls] add(lhs, rhs)", "[zls] add(lhs: i32, rhs: i32) active=rhs", "diag:fresh:zls", "format:zls:applied", "ZLS", "mode:normal"), max_key_events=17, prelude=LSP_ASSIST_PRELUDE),
Scenario("dirty-discard-shift-q", 52, 12, "empty", "ios-default-qwertz-space-path", "dirty-discard", "truecolor", "file", setup_empty, tuple(bytes([b]) for b in b" ps Q"), "", ("1│", "")),
Scenario("directory-panel-narrow", 52, 12, "directory", "ios-default-qwertz-space-path", "panel", "mono", "directory", setup_directory, PANEL_QUIT, None, ("file", "one.zig"), required_attrs=()),
]
@@ -503,7 +518,12 @@ def run_one(mim: Path, root_out: Path, scenario: Scenario) -> tuple[str, Path]:
target, expected_initial = scenario.setup(tmp)
_ = expected_initial
launch_arg = target.relative_to(tmp).as_posix()
pid, fd = spawn_under_pty([str(mim), launch_arg], scenario.width, scenario.height, scenario.color_mode, tmp)
argv = [str(mim), launch_arg]
if scenario.prelude:
prelude_path = tmp / "e2e-prelude.trace"
prelude_path.write_text(scenario.prelude + "\n", encoding="utf-8")
argv = [str(mim), "--e2e-prelude-file", prelude_path.name, launch_arg]
pid, fd = spawn_under_pty(argv, scenario.width, scenario.height, scenario.color_mode, tmp)
transcript = bytearray()
grid = TerminalGrid(scenario.width, scenario.height)
try: