Skip to content

cli(test[vt]): add libvt invariant and syrupy snapshot tests - #604

Open
tony wants to merge 5 commits into
fix/602-603-cli-terminal-alignmentfrom
test/595-libvt-cli-snapshots
Open

tony wants to merge 5 commits into
fix/602-603-cli-terminal-alignmentfrom
test/595-libvt-cli-snapshots

Conversation

@tony

@tony tony commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

Fixes #595

Summary

  • Add libvt[pytest,syrupy] to dev and testing groups on Python 3.12+ with zero runtime dependency.
  • Verify DEC Mode ?2026 hold atomicity, DL panel collapse, CJK truncation, and resize reflow.
  • Exercise live vcspull sync resize and SIGINT cleanup inside a POSIX PTY via vt_pty.
  • Snapshot CLI subcommands, color modes, log and help formatters, sync error and recovery flows, watchdog timeouts, interactive trust prompts, and sequential and parallel PTY runs with syrupy.

Companion PR

Changes

  • pyproject.toml, uv.lock: add libvt[pytest,syrupy]>=0.0.1a5,<0.1; python_version >= '3.12' to dev and testing, exempt libvt in [tool.uv.exclude-newer-package], and allow unresolved libvt imports under [tool.ty.analysis] on Python 3.11.
  • tests/cli/test_vt_progress.py: add deterministic VT state-machine and vt_pty invariant tests for DEC Mode ?2026 hold atomicity, sequential DL panel collapse, 60x8 parallel overflow capping, 80x24 CJK width truncation and split-chunk reassembly, 100x24 to 58x20 narrowing reflow, PlanProgressPrinter and StatusProgressPrinter carriage-return overwrite padding, DECTCEM ?25 cursor visibility across warm-grace runs, and live PTY resize and SIGINT termination.
  • tests/cli/test_vt_snapshots.py, tests/cli/__snapshots__/test_vt_snapshots.ambr: add .ambr boxed screen, step-delta, and SGR span snapshots across SyncStatusIndicator (including mid-spinner target_drift DL panel collapse and retained RecoveryToken notices), vcspull sync --dry-run, missing working_copy.branch guidance, --include-worktrees live column alignment and dirty-checkout refusal, vcspull status --detailed, vcspull list --tree --include-worktrees, vcspull search mid-token highlighting, SimpleLogFormatter, VcspullHelpFormatter, and live vt_pty vcspull sync runs covering normal and narrow widths, --jobs 2 mixed parallel outcomes, --timeout 1 watchdog rerun recipes, --exit-on-error batch aborts, mid-sync SIGINT cleanup, and escaping project config [y/N/always/?] drill-down and acceptance into live sync.

Design decisions

  • Gate both VT test modules with importlib.util.find_spec("libvt") and module-level pytest.mark.skipif instead of pytest.importorskip("libvt") so pytest collects every parametrized item on Python 3.11 and records skipped locations in syrupy rather than failing unused-snapshot checks.

Test plan

  • Verify formatting and lint rules with uv run ruff format --check . and uv run ruff check .
  • Verify static types on Python 3.11 and Python 3.15 with uv run ty check --error-on-warning --python-version 3.11 . and uv run ty check --error-on-warning --python-version 3.15 .
  • Run the full test suite and .ambr snapshot assertions on Python 3.15 with uv run py.test -q
  • Verify clean skips and zero unused syrupy snapshot errors on Python 3.11 with uv run --python 3.11 --isolated --group testing pytest tests/cli/test_vt_progress.py tests/cli/test_vt_snapshots.py tests/cli/test_add.py -q
  • Verify isolated wheel runtime dependencies with uv run --isolated --no-cache --no-dev --no-editable --frozen python scripts/runtime_dep_smoketest.py

tony added 3 commits December 1, 2026 18:53
why: Provide a virtual terminal state machine, POSIX PTY harness, and
syrupy .ambr screen and SGR serializer for CLI rendering tests on Python
3.12+ without adding a runtime dependency on vcspull.

what:
- Add libvt[pytest,syrupy]>=0.0.1a5,<0.1 on Python >=3.12 to dev and
  testing dependency groups
- Exempt libvt from uv exclude-newer cooldowns
- Allow unresolved libvt imports in ty on Python 3.11
- Refresh uv.lock
why: Raw io.StringIO substring checks verify emitted ANSI bytes without
checking what an ANSI/DEC terminal renders on screen or leaves in
scrollback across ?2026 frames, DL panel collapses, CJK truncation,
narrowing reflows, and live PTY signals.

what:
- Add DEC Mode ?2026 hold-atomicity tests for sequential and parallel
  SyncStatusIndicator frames via Terminal.feed_until and StopOn
- Verify sequential --jobs 1 3-row panel DL collapse leaves zero blank
  gaps or scrollback residue
- Verify 60x8 parallel overflow capping, 80x24 CJK 2-cell truncation and
  split-chunk reassembly, 100x24 -> 58x20 mid-run resize reflow, and
  carriage-return padding in PlanProgressPrinter and StatusProgressPrinter
- Verify DECTCEM ?25 warm-grace stability and live POSIX vt_pty resize
  and SIGINT (\x03) cleanup
why: Lock in boxed visual layout and SGR span positions across
SyncStatusIndicator transitions, CLI color modes, log/help formatters,
and live PTY sync sessions while skipping cleanly on Python 3.11.

what:
- Snapshot sequential and parallel SyncStatusIndicator frames and
  vt_screen(after, diff=before) step-deltas
- Snapshot sync --dry-run, status --detailed, list --tree
  --include-worktrees, search mid-token cyan/magenta/cyan highlighting,
  SimpleLogFormatter, and VcspullHelpFormatter across --color auto,
  --color always, --color never, and NO_COLOR=1
- Snapshot end-to-end vcspull sync in vt_pty at 76-column and 48-column
  terminal widths

Fixes #595
@codecov

codecov Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.75%. Comparing base (028ad43) to head (5e46b7a).

Additional details and impacted files
@@                          Coverage Diff                           @@
##           fix/602-603-cli-terminal-alignment     #604      +/-   ##
======================================================================
+ Coverage                               85.26%   85.75%   +0.48%     
======================================================================
  Files                                      39       39              
  Lines                                    6829     6829              
  Branches                                 1379     1379              
======================================================================
+ Hits                                     5823     5856      +33     
+ Misses                                    669      644      -25     
+ Partials                                  337      329       -8     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tony
tony changed the base branch from master to fix/602-603-cli-terminal-alignment December 2, 2026 01:55
why: Live multi-slot compaction, watchdog timeouts, mid-spinner log
warnings, retained recovery notices, Ctrl-C cleanup, and interactive
escaping-config prompts combine relative cursor rewrites with styled
stdout/stderr output that plain stream capture cannot verify visually.

what:
- Snapshot parallel --jobs 2 PTY live slot compaction, mixed outcomes,
  and step delta
- Snapshot --timeout 1 PTY live panel, 32-column aligned rerun recipe,
  debug log trail, and scrollback viewport offset
- Snapshot missing working_copy.branch guidance, mid-spinner
  target_drift DL panel collapse, retained recovery tokens, 20-column
  aligned --include-worktrees outcomes, and --exit-on-error PTY abort
- Snapshot live PTY SIGINT mid-sync panel, cleanup summary, and delta
- Snapshot escaping project config [y/N/always/?] drill-down, decline,
  and acceptance into live sync spinner
- Refresh dry-run include_worktrees snapshot for 20-column ref padding

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add libvt terminal invariant and syrupy snapshot tests for CLI output

1 participant