Skip to content

test: stabilize view model golden output - #1752

Open
jackwalkerlabs wants to merge 1 commit into
charmbracelet:mainfrom
jackwalkerlabs:fix/view-model-test-flake
Open

test: stabilize view model golden output#1752
jackwalkerlabs wants to merge 1 commit into
charmbracelet:mainfrom
jackwalkerlabs:fix/view-model-test-flake

Conversation

@jackwalkerlabs

@jackwalkerlabs jackwalkerlabs commented Aug 4, 2026

Copy link
Copy Markdown

Closes #1746.

TestViewModel compares the complete terminal output against golden files, but its program uses the default 60 FPS renderer ticker. Under the race detector with GOMAXPROCS=1, that ticker can flush an intermediate frame before Quit is handled, making valid renderer timing change the escape-sequence ordering.

Run this short golden-output test at 1 FPS so the asynchronous renderer tick stays outside the test window. Production behavior is unchanged, and the existing golden files remain unchanged.

Validation:

  • go test -race -count 1000 -cpu 1 -run TestViewModel ./...
  • go test -race -count 4 -cpu 1,4 ./...
  • go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.9.0 run
  • git diff --check

@xevrion

xevrion commented Aug 4, 2026

Copy link
Copy Markdown

Thanks for picking this up. I'd proposed this fix in #1746 and had it on a branch, so I'm glad either way as long as it lands.

One suggestion for the PR body: it's worth stating explicitly that the golden files are unchanged. That's the part that shows the recorded ordering was always correct and only the timing was unstable, which makes the fix easier to review than if it came with regenerated testdata.

@jackwalkerlabs

Copy link
Copy Markdown
Author

Good point鈥攗pdated the PR body to state explicitly that the golden files are unchanged. Thanks for confirming the direction.

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.

TestViewModel is flaky under the Taskfile's test flags

2 participants