Repository navigation
Conversation
✅ Integration test reportCommit: 0bed5ff
Top 3 slowest tests (at least 2 minutes):
|
|
/review |
7f68a1a to
58b99e3
Compare
|
/review |
There was a problem hiding this comment.
Automated review at 58b99e3. Each finding was verified against the code.
Not ready yet: part of the automated review did not complete.
This PR adds test infrastructure to pin current Charm v1 TUI behavior ahead of a v2 migration, so the swap surfaces its changes as golden diffs. Production changes are minimal and behavior-neutral: an unexported colorFromEnv helper, a NewTestIOWithOptions test constructor, and a RunWithOptions entry point for tableview. The test harness extensions (styled/modes/queries goldens, responder, leftover capture) are well-documented and the 103 golden files serve their stated sentinel purpose. After tracing every candidate claim against the code, no defects survive.
|
/review |
There was a problem hiding this comment.
Automated review at 58b99e3. Each finding was verified against the code.
Not ready yet: part of the automated review did not complete.
This PR adds a golden-based harness (styled screens, mode and query logs, a terminal responder, leftover input) and pins current Charm v1 TUI behaviour ahead of the v2 migration. It also adds two test seams in cmdio and tableview. Production behaviour looks unchanged. The problems are in the test code: two pager pins still race their input, and several comments and doc strings describe mechanisms that don't work the way they say. The leftover path is also never exercised with real bytes.
|
|
||
| // captureLeftover runs on the program goroutine after the program returns | ||
| // and before the input pipe is closed. | ||
| func (tt *Term[T]) captureLeftover() { |
There was a problem hiding this comment.
[nice to have] With v1 no pin writes a query, so scheduleReplies never writes a byte and captureLeftover only ever reads an empty pipe. Every leftover golden is (none). If Leftover is broken (for example, bubbletea's read loop takes the bytes before io.ReadAll), the v2 migration still gets (none) and reads it as "no leftover" rather than a harness failure. Can you add a termtest unit test where a program writes \x1b]11;?\x1b\\ and returns, with Responder{Delay: …} and CaptureLeftover, and assert that Leftover returns DefaultReply("OSC 11")? A second case could type bytes the program never reads.
58b99e3 to
65797a0
Compare
da0bbaf to
1705d71
Compare
NewTestIOWithOptions lets tests set the templates, color environment and redirected streams that NewTestIO leaves off. The color environment lookup moves into colorFromEnv so NewIO and the test path share it. tableview.RunWithOptions lets tests supply input and an initial window size. Run calls it with zero options, so production behaviour is unchanged. Both seams are behaviour-neutral when given their zero values. Co-authored-by: Isaac <no-reply@databricks.com>
…put helpers
Opt-in capabilities for pinning what a command writes to a terminal:
- GoldenStyled renders SGR as inline markers ({fg=4}?{/}, {bold}).
- GoldenModes logs mode changes and the modes still active on exit,
covering cursor visibility, bracketed paste, alternate screen, mouse,
kitty keyboard and modifyOtherKeys.
- GoldenQueries logs terminal queries (DECRQM, kitty flags, OSC 11, CPR,
DA1/DA2, XTVERSION). Responder answers them after a delay.
- Leftover reports input bytes unread at exit (Unix only).
- TypeBurst, Paste, Settle, WaitForScreen and WaitForOrExit cover input
and timing that the existing helpers could not express.
- Options gains Env, ColorFromEnv, stream redirection, templates,
screen rows and newline mapping.
Existing goldens and default behaviour are unchanged.
Co-authored-by: Isaac <no-reply@databricks.com>
Adds pin tests that record what the Charm v1 prompt, select, spinner, pager, tableview and LogString do today: keys (burst input, Alt and Shift+Enter, kitty Esc, paste), colors across TERM, CI, CLICOLOR and NO_COLOR, terminal modes on exit, terminal queries and leftover replies, pager paging and spinner frames, tableview search input, and stderr styling when a stream is redirected. The goldens under testdata/ are the reference. When the v2 swap lands, these tests fail and the golden diffs show the exact user-visible change. Regenerate with -update only for an intended change. Co-authored-by: Isaac <no-reply@databricks.com>
Nothing observable tells whether Enter reached the pager during the first fetch or at the prompt after it, and both drain the list to the same screen. Drop the wait that could not tell them apart and rename the test to TestPagerPin_EnterDrainsRemainingPages. Co-authored-by: Isaac <no-reply@databricks.com>
1705d71 to
0bed5ff
Compare
This PR pins current Charm v1 TUI behaviour, so the Charm v2 migration shows its exact user-visible changes as golden diffs.
Changes
Test infrastructure only. No production behaviour changes.
Two behaviour-neutral seams for tests, both with zero-value defaults that keep production behaviour:
cmdio.NewTestIOWithOptionstakes templates, the color environment and redirected streams. The color-from-environment lookup moves intocolorFromEnv, shared byNewIOand the test path.tableview.RunWithOptionstakes an input and an initial window size.Runcalls it with zero options.termtestcapabilities (all opt-in; existing goldens unchanged):{fg=4}?{/},{bold},{fg=@208},{fg=#8fb3dc}), covering SGR colors, bold, faint, italic, underline styles (4:n,21), blink, reverse, strikethrough and overline. Colon and semicolon color forms are decoded.GoldenModes): every set and reset is recorded, so a repeated write shows as a diff. Covers cursor visibility, bracketed paste, alternate screen, mouse, kitty keyboard, modifyOtherKeys and DECST8C.GoldenQueries): DECRQM, kitty flags, OSC 10/11, CPR, DA1/DA2, XTVERSION. AResponderanswers them after a delay.Leftoverreports input left unread on exit. It closes the harness's end of the input pipe and reads to EOF, so it needs no platform-specific reads. Its tests are skipped on Windows.TypeBurst,Paste, key constants for Alt and Shift+Enter forms, andSettle, which waits until output is quiet.WaitForScreen,WaitForOrExit,WaitForRepliesandWaitForExit.Options:Env,ColorFromEnv, stream redirection, templates,ScreenRows(non-positive values use the default),MapNewlineandNormalize(applied to screen snapshots only).LogRawOnFailurelogs the raw output stream when a test fails.Pinned areas (
libs/cmdio/cmdiotest/pin_*_test.go, 103 new goldens undertestdata/):TERM(unset, xterm-256color, screen, vt100, dumb),CI,CLICOLOR=0,NO_COLOR, tmux with truecolor andCOLORTERM. The harness screen is a pipe, so these pin cmdio's color decisions, not the color depth a real terminal gets;databricks selftest tui colorsandprofile(selftest: add TUI commands for live-terminal testing #7688) cover that by hand.LogStringwrites to a redirected stderr.LogStringitself writes its bytes unchanged. The SGR is stripped by the color helpers and the renderer, and the goldens show the effect.The goldens are the reference. When the v2 swap lands these tests fail, and the golden diffs show the exact change. Regenerate with
-updateonly for an intended change.Known flake:
TestPagerPin_SpaceLoadsNextPageonce showed the second page over the first. It has not recurred since the test waits for output to settle before pressing space. On failure the test logs the raw output stream for diagnosis.Waits that gate a golden fail the test on timeout. Two waits are deliberately tolerant, and say so at the call site: the spinner-frame count (the count is the pinned value) and the select's second cursor hide (a version that hides once must still reach its golden).
No
.nextchangesfragment: this is test-only.Reading order
libs/cmdio/cmdiotest/termtest/*.goand its tests.libs/cmdio/testing.goandlibs/tableview/tableview.go.libs/cmdio/cmdiotest/pin_*_test.go. Each test's comment says what it pins and why.Why
The v2 migration changes key decoding, color detection, the bytes written when a TUI starts and exits, and paging/search behaviour. The existing tests run against pipes and an emulator, so they cannot show what changes for a user. Pinning the current v1 behaviour first makes each intended change a reviewable golden diff.
Some v1 behaviour pinned here is accidental (for example, Alt+Enter submits, and a late OSC 11 reply is typed into the prompt). The pins record it so the migration decides on each change explicitly rather than inheriting it silently.
Tests
go build ./...,go vet(linux, darwin, windows) and golangci-lint on./libs/cmdio/...and./libs/tableview/...pass. gofmt is clean.TERM=xterm-256color go test -race -count=10 ./libs/cmdio/...passes.-race -run Pin -count=10and 1 round of the same under 8 CPU-hog processes: zero failures. One full-package-race -count=3run failed once onTestSelectBaseline_EscKey(a key typed just before a snapshot was read before its echo). It has not reproduced: four further cmdiotest-only runs and a full./libs/cmdio/...run passed, and the test passes 10 of 10 in isolation. It does not useSettleorLeftover.go teston./libs/cmdio/cmdiotest/passes withTERM=dumband withTERMunset.go test ./cmd/auth/... ./libs/tableview/...passes.go test ./acceptance/...passes.testdatadiff against the base contains only added files.This pull request and its description were written by Isaac.