Skip to content

test(terminal): a busy runner gets more attempts to send a key byte by byte - #153

Merged
Derrors merged 2 commits into
mainfrom
test/terminal-key-spread
Nov 18, 2026
Merged

Derrors merged 2 commits into
mainfrom
test/terminal-key-spread

Conversation

@Derrors

@Derrors Derrors commented Nov 18, 2026

Copy link
Copy Markdown
Owner

What and why

macos-terminal failed twice on 2026-11-18 with nothing wrong in the menu (#151's first run, #152's first run); a re-run passed both times:

AssertionError: could not send b'\xe4\xb8\x8d' within 0.2s: took [0.238, 0.301, 0.302, 0.326, 0.278]
AssertionError: could not send b'\x1bOB' within 0.2s: took [0.263, 0.206, 0.229, 0.235, 0.292]

tests/terminal.py sends a key one byte at a time, 40 ms apart (80 ms for three bytes), and throws away an attempt whose writes took longer than 0.2 s: the script was held up, which says nothing about the menu's 250 ms SEQUENCE_WAIT. It allowed five attempts. On a busy runner every sleep was stretched for a while, so all five were thrown away.

The check now tries up to 30 times within 20 s, prints how many attempts a key took when it needed more than one (to see in CI logs how busy the runner was), and a failure names the count. The 0.2 s budget, the 40 ms gap and what is checked don't change.

A second commit adds what the axauditd stall of regression case #155 was traced to (only right after the lock button, the cause is inside axauditd; what was tried).

Tests

1. Unit tests

  • python3 tests/terminal.py --binary target/debug/iphone-control --test-dir target/debug/deps passes (Debian 12, in Docker)
  • The retry path, with a copy of the script whose sleeps randomly took 0.2 s instead of 0.04 s half the time: every key passed after 5–7 attempts (the old limit of 5 would have failed two of them) and the note was printed: note: sending b'\x1b[B' took 7 attempts (the slow ones: [0.24, 0.24, 0.24, 0.4, 0.24, 0.24])
  • The give-up path, with a copy whose budget was 0: could not send b'\x1b[B' within 0.0s in 30 attempts: took [0.080…]
  • tests/check_regression_cases.py: 155 cases, 0 missing
  • No existing test removed, ignored or loosened: the budget is the same; only the number of attempts that prove nothing is larger

2. Real-device regression

  • Not needed: the change doesn't touch code that talks to a phone (a test script and a doc row)

3. Regression cases

4. Real-device proof

  • Not applicable: no bug fix or feature in the product

Checklist

  • MCP tool names, parameters and default outputs unchanged
  • No dependency changes
  • No CHANGELOG line: tests and docs only
  • No private data

🤖 Generated with Claude Code

Derrors and others added 2 commits November 18, 2026 10:18
…y byte

The fragmented-key check throws away an attempt whose writes took longer
than 0.2 s (the script was held up, which proves nothing about the menu)
and tries again, five times at most. A busy macOS runner stretched every
sleep for longer than that: five attempts in a row took 0.21-0.33 s, and
macos-terminal failed twice on 2026-11-18 (#151, #152) with nothing wrong
in the menu.

It now tries up to 30 times within 20 s, says how many attempts a key
took when it needed more than one, and the failure names the count. The
budget, the gap between bytes and what is checked are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Only right after the lock button with a read following; what was tried
and didn't reproduce it; the cause is inside axauditd.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Derrors
Derrors merged commit 8770ef8 into main Nov 18, 2026
7 checks passed
@Derrors
Derrors deleted the test/terminal-key-spread branch November 18, 2026 09:08
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.

1 participant