Files
haikdcandGitHub 9c95342704 Haik/feat/test runner (#86)
* [haik]: ckpt, added in the test runner skelton i made in another repo -> still gotta make tweaks to fold it onto the current repo

* [haik]: restructure backend test layout: move 37 test files from backend/tests/ into backend/tests/test_cases/, add backend/tests/run.sh one-command launcher that auto-provisions both runner and test venvs with stamp-based caching, update runner config.json to point test_paths at test_cases/ and fix venv_python path, revise runner README with run.sh usage and clearer setup instructions, and gitignore the .runner-venv directory

* [haik]: refactor: reorganize backend/tests/test_cases from flat structure into domain subdirectories — moved 36 test files into auth/, browser/, labeling/, service/, settings/, and web_search/ for better discoverability and grouping

* [haik]: overhaul test picker UI and add post-run rerun loop: replace checkbox glyphs with fzf-style row recolouring (coral=full, lighter coral=partial) and a right-pinned selection dot, add config-driven icon tiers (nerd/emoji/unicode/ascii) with per-glyph graceful degradation, replace the modal -k keyword screen with an inline live-filtering search bar that prunes the tree on every keystroke, add warm Anthropic-dark coral theme, toolbar flag chips replacing the old status line, and a floating help badge overlay; add rerun_prompt.py with inline Textual pill prompt (rerun all/failed/passed/exit) shown after each TTY run, wire it into main.py as a post-run loop; change run_tests to return (exit_code, RunSummary) tracking collected/passed/failed node IDs via new Dashboard methods; add icons field to config.py and config.json (set to nerd), document icon tiers and Nerd Font setup in README, set Hack Nerd Font in .vscode/settings.json, add .runner-venv to linter excludes
2026-06-14 07:02:30 -07:00

32 lines
1.3 KiB
Python

"""Wire protocol shared by the parent runner and the subprocess worker.
The worker (running in the *test* venv) writes one JSON object per line to an
inherited pipe FD; the parent (running in the *runner* venv) reads them and
drives the Rich dashboard. This module is deliberately dependency-free (only the
stdlib) so it imports cleanly in *both* venvs — no rich, textual, or pytest.
Ordering guarantee: both control events and streamed ``-s`` output are written
through :func:`emit` to the *same* FD from the *same* process, so an OUTPUT
event always lands between its test's LOGSTART and LOGFINISH.
"""
from __future__ import annotations
import json
import os
# Event types (the "type" field of every framed message).
COLLECTION = "collection" # {"items": [nodeid, ...]}
LOGSTART = "logstart" # {"nodeid": ...}
LOGREPORT = "logreport" # {nodeid, when, passed, failed, skipped, duration, capstdout, capstderr, longreprtext}
LOGFINISH = "logfinish" # {"nodeid": ...}
OUTPUT = "output" # {"line": ...} (streamed -s test output)
COVERAGE = "coverage" # {"rows": [[rel, stmts, miss, pct], ...], "total": float}
DONE = "done" # {"code": int}
def emit(fd: int, obj: dict) -> None:
"""Write one framed event to ``fd``. Unbuffered to preserve ordering."""
data = (json.dumps(obj) + "\n").encode("utf-8")
os.write(fd, data)