claudetui tests: a deadline case cut off before its screen was drawn runs again (#5429)

The retry ported from Fldicoahkiin's 165e33d89 (the commit before this)
reran a case only when the helper said "showed no prompt". The "banner,
no /usage panel" case, added after that fix was written, can be cut off
one step later on a loaded machine: Claude Code is up, "/usage" is
typed, and the deadline comes before the banner is drawn again. The
helper then says "hadn't drawn /usage's panel in the 6s …: ❯ /usage",
the right words with none of the case's screen, and the case failed.
With FAKE_SLOW_START=3500ms it was red 2 runs of 2 at the ported commit.

A case with a screen of its own now runs again, with twice the time up
to 12s, whenever that screen isn't in what the helper said; a case with
none (no prompt, no /usage panel) as before, on "showed no prompt". One
whose screen is there with the wrong words still fails at once.

Ran at this head (origin/main 3173c4f41 + 165e33d89 + this), on mote:
- go test -count=1 ./internal/claudetui: ok (195s)
- FAKE_SLOW_START=3500ms go test -count=3 -run
  TestShimEndsAtItsCallersDeadline: ok (203s)
- wsl-run: the test, and again with FAKE_SLOW_START=3500ms: ok
- gofmt -l internal/claudetui: clean
The full go test ./... at 30de93e9e had this test red (no_/usage_panel,
"nothing on its screen (0 bytes read)"), the shape #5429 names.

Broken by hand: the retry capped at 3s, with FAKE_SLOW_START=3500ms:
all 7 cases red; restored, green.

Not tried: Windows (the test needs a pty).
This commit is contained in:
yetone
2026-11-16 01:36:46 +08:00
parent f3a758b734
commit 9e627c5079
+5 -3
View File
@@ -1063,7 +1063,9 @@ func TestShimEndsAtItsCallersDeadline(t *testing.T) {
// them up: "showed no prompt in the 2.8s" at load 13-20, and
// in other full runs (#5079). A run that ended at it with no
// prompt shown, before Claude Code drew what the case is about,
// says nothing of the case, and runs again with twice the time.
// says nothing of the case, and runs again with twice the time;
// so does one that ended after the prompt but before the case's
// screen was drawn (the banner case, "❯ /usage" alone).
// One whose screen has it is told as it is: the helper misread it.
for wait := 3 * time.Second; ; wait *= 2 {
start := time.Now()
@@ -1073,8 +1075,8 @@ func TestShimEndsAtItsCallersDeadline(t *testing.T) {
if err == nil || strings.Contains(out, `"type":"result"`) {
t.Fatalf("ended %v, wrote %q", err, out)
}
notUp := strings.Contains(stderr, "claude-tui: Claude Code showed no prompt in the ") &&
(c.screen == "" || !strings.Contains(stderr, c.screen))
notUp := c.screen == "" && strings.Contains(stderr, "claude-tui: Claude Code showed no prompt in the ") ||
c.screen != "" && !strings.Contains(stderr, c.screen)
if notUp && wait < 12*time.Second {
t.Logf("not up in %s, again with %s: %q", wait, 2*wait, stderr)
continue