Skip to content

test(tui): check the TUI pid option is unset in a way tmux 3.2a agrees with - #742

Open
JDProfresh wants to merge 1 commit into
Ark0N:masterfrom
JDProfresh:test/tui-guard-tmux-3.2
Open

JDProfresh wants to merge 1 commit into
Ark0N:masterfrom
JDProfresh:test/tui-guard-tmux-3.2

Conversation

@JDProfresh

Copy link
Copy Markdown
Contributor

test/tui/tui-switch-guard.test.ts asserts that disarmTuiSwitchGuard() removed the @codeman-tui-pid option by expecting tmux show-options -gv @codeman-tui-pid to throw, but on tmux 3.2a an unset user option is not an error: it prints nothing and exits 0. So npm test is red on Ubuntu 22.04 even though the option is gone.

Problem

On a clean 1.47.0 (f1f7eec4) on Ubuntu 22.04 with its packaged tmux 3.2a:

FAIL  test/tui/tui-switch-guard.test.ts > TUI M-1..M-9 switch only the attaching client > switches the armed client only, including after that client has died
AssertionError: expected [Function] to throw an error
 ❯ test/tui/tui-switch-guard.test.ts:239:68

CI stays green because its ubuntu-24.04 runners have a newer tmux. The line came in with the #688 release-prep review (46774b71).

Cause

The same show-options -gv on an unset user option, on a private socket:

tmux output exit
3.2a (Ubuntu 22.04) empty 0
3.5a (Alpine 3.22) invalid option: @codeman-tui-pid 1

The code under test already handles both: disarmTuiSwitchGuard() treats a thrown read and an empty one alike (if (!pid) return;). Only the test depends on the version.

What it does

The assertion reads the global option listing, show-options -g, and expects @codeman-tui-pid to be absent. On both versions the listing contains @codeman-tui-pid 123 while the option is set and leaves it out once set-option -gu has run. That matches the list-keys and show-hooks absence checks the same test already uses. Nothing outside the test changes.

Tests

  • npm test -- test/tui/tui-switch-guard.test.ts on tmux 3.2a: red on 1.47.0, green 3 of 3 with the change.
  • The guard still bites: with the set-option -gu @codeman-tui-pid call in disarmTuiSwitchGuard() commented out, the new assertion fails (expected '@codeman-tui-pid 1671450\n…' not to contain '@codeman-tui-pid').
  • I didn't run the vitest file on a newer tmux. The tmux 3.5a behaviour in the table was measured directly in a container, and the old assertion passing in upstream CI shows that newer tmux throws.
  • Full gate on the branch: static checks green, npm test 13,504 passed (13,503 plus test/frontend-public-tooling.test.ts, which needed the spreadsheet preview assets generated in my fresh worktree and passes 4 of 4 after that).

…s with

An unset user option makes `show-options -gv` exit 1 on newer tmux but print nothing and exit 0 on 3.2a (Ubuntu 22.04), so the disarm assertion failed there although the option was gone. Assert on the global listing instead, which omits an unset option on both.
@Ark0N

Ark0N commented Oct 31, 2026

Copy link
Copy Markdown
Owner

Thanks @JDProfresh for tracking this down. The PR makes test/tui/tui-switch-guard.test.ts check that @codeman-tui-pid is gone by reading the global option listing instead of expecting show-options -gv to fail, so the test no longer depends on how a given tmux reports an unset user option.

I ran it here on tmux 3.4: the file passes, the whole test/tui/ directory passes (403 tests), and with the set-option -gu @codeman-tui-pid call in disarmTuiSwitchGuard() commented out the new assertion at line 241 fails as it should. show-options -g leaves hooks out, so the hook text that names the option cannot trip it either. Typecheck, lint, frontend syntax and format checks are green.

Nothing to change. This merges as it stands once the remaining CI job finishes. Thanks again for the clear write-up and the tmux version table.

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.

2 participants