Skip to content

test(tui): a gated scenario for /diagnostics with a server running - #113

Merged
yusiwen merged 2 commits into
masterfrom
test/lsp-diagnostics-scenario
Oct 4, 2026
Merged

yusiwen merged 2 commits into
masterfrom
test/lsp-diagnostics-scenario

Conversation

@yusiwen

@yusiwen yusiwen commented Oct 4, 2026

Copy link
Copy Markdown
Owner

Refs #111 (merged as the fix this guards).

What changed

  • tui/testdata/scenarios/lsp-diagnostics.scenario — the /diagnostics outcome No LSP diagnostics., which is only reachable once a language server is running. Gated by LSP_TEST, so a plain make test skips it.
  • make test-tui-lsp — runs that scenario gated the same way make test-lsp gates the lsp/ tests, and for the same reason: it needs gopls on PATH.
  • tui/testdata/stub/openai_stub.py — a read mode. Reading a file is what starts the server (the warmup in tool/filesystem.go is the reachable path after [lsp] The client can never start: every path that would start it is gated on it #111). Unlike the two stub modes added earlier in this work, a scenario actually uses this one.
  • CI's lsp job runs make test-tui-lsp, next to the make test-lsp step it already had — that job already provides gopls, so the scenario is a gate there rather than a file nobody runs.
  • docs/tui-verification.md and AGENTS.md list the scenario and its gate.

Why this string

No LSP diagnostics. is the third of /diagnostics'"'"'s three outcomes. Before #111 it was unreachable — the client could never start — so the scenario doubles as a regression guard: if the circle returns, the warmup never runs, IsAvailable() stays false, and the status line says LSP not available instead. The listing outcome is deliberately not covered: it needs real diagnostics present.

Verification

Check Result
make test-tui-lsp (run 1) ok, exit 0
make test-tui-lsp (run 2) ok, exit 0
make test-tui-scenarios unaffected — the file is skipped without LSP_TEST
ad-hoc capture (the basis for the assertion) LSP: gopls started for /Users/yusiwen/git/mine/TinyCode, then /diagnostics → No LSP diagnostics.

Honest scope

The gated scenario ran here with gopls from this repository'"'"'s own flake (v0.23.0) on PATH — a plain shell has no gopls, which is exactly why it is gated. CI'"'"'s lsp job is where it runs unattended.

Follow-ups

  • The LSP tool path (lsp/tools.go:81) still gates on IsAvailable(). Fine while a file operation happens first; worth revisiting if a session only uses LSP tools.
  • The listing outcome (diagnostics present) is uncovered.

The third outcome of /diagnostics — "No LSP diagnostics." — was unreachable before issue
#111, because the LSP client could never start; with that fixed, the string is a property
worth pinning. It is only printed when a client exists, so asserting it also guards the fix:
if the circle returns, the status line says "LSP not available" instead.

- The stub gains a "read" mode: reading a file is what starts the server (the warmup in
  tool/filesystem.go is the reachable path after #111), and the scenario needs the server up
  before /diagnostics can say anything else. Unlike the earlier stub modes, a scenario uses
  this one.
- The scenario is gated by LSP_TEST because it needs gopls on PATH: `make test-tui-lsp` runs
  it, CI's lsp job already provides gopls, and a plain `make test` skips it.
- The server comes up the way a user brings it up — a file read — so the scenario is a
  cold-start regression guard, not a mock.

Measured: gated run twice, 0 failures; the earlier ad-hoc capture showed
"LSP: gopls started for /Users/yusiwen/git/mine/TinyCode" and /diagnostics reporting
"No LSP diagnostics." where it previously reported "LSP not available".

Not covered: the listing outcome needs real diagnostics present, and the LSP *tool* path
still gates on IsAvailable() (fine while a file operation happens first).
@yusiwen yusiwen added the tests Test coverage and test infrastructure label Oct 4, 2026
Two CI failures in the previous commit, both mechanical:

- the tui-visual job picked the file up through the *.scenario glob and ran it without gopls,
  because the suite skips by filename pattern (*live-*) and the new file matched none. It now
  has its own pattern and says which target runs it;
- test-tui-lsp failed at its screenshot step because the shots directory is created by the
  other target, not by this one. It creates it now.

Verified: with gopls off PATH the suite reports the file as skipped and stays green (the way
the tui-visual job sees it); with gopls on PATH make test-tui-lsp passes, ok: 14 steps.
@yusiwen
yusiwen merged commit d90ff84 into master Oct 4, 2026
8 checks passed
@yusiwen
yusiwen deleted the test/lsp-diagnostics-scenario branch October 4, 2026 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests Test coverage and test infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant