Visitar URL original
test(builder): deterministic pane-setup abort · tmux-python/tmuxp@986ed91 · GitHub
Skip to content

Commit 986ed91

Browse files
committed
test(builder): deterministic pane-setup abort
why: the synchronize-restore-on-abort test triggered the abort with an invalid tmux layout. tmux's invalid-layout wording varies by version and crashes the server outright on tmux 3.3a, so the test failed across the CI matrix though it passed on a single local tmux version. what: - Inject the abort in Python by monkeypatching iter_create_panes to raise, after synchronize-panes is disabled and before it is restored - Drop the version-fragile invalid-layout trigger and its message match
1 parent 5276b2d commit 986ed91

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

‎tests/workspace/test_builder.py‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2280,6 +2280,7 @@ def test_synchronize_restores_state_when_pane_setup_aborts(
22802280
plugin_synchronize: bool | None,
22812281
expected_local_sync: bool | None,
22822282
expected_effective_sync: bool,
2283+
monkeypatch: pytest.MonkeyPatch,
22832284
) -> None:
22842285
"""Pane setup failures restore temporarily disabled synchronize-panes state."""
22852286

@@ -2303,7 +2304,6 @@ def after_window_finished(self, window: Window) -> None:
23032304

23042305
window_config: dict[str, t.Any] = {
23052306
"window_name": f"sync-abort-{test_id}",
2306-
"layout": "not-a-layout",
23072307
"panes": [
23082308
"printf '__PANE0__\\n'",
23092309
"printf '__PANE1__\\n'",
@@ -2325,7 +2325,18 @@ def after_window_finished(self, window: Window) -> None:
23252325
plugins=plugins,
23262326
)
23272327

2328-
with pytest.raises(LibTmuxException, match="invalid layout"):
2328+
# Abort pane setup deterministically. A tmux-triggered abort (e.g. an
2329+
# invalid layout) is unusable here: its error wording varies by tmux
2330+
# version and some versions crash the server outright. Inject the
2331+
# failure in Python instead, after synchronize-panes is disabled and
2332+
# before it is restored.
2333+
def _abort_pane_setup(*args: t.Any, **kwargs: t.Any) -> t.NoReturn:
2334+
msg = "simulated pane setup failure"
2335+
raise LibTmuxException(msg)
2336+
2337+
monkeypatch.setattr(builder, "iter_create_panes", _abort_pane_setup)
2338+
2339+
with pytest.raises(LibTmuxException, match="simulated pane setup failure"):
23292340
builder.build(session=session)
23302341

23312342
window = session.windows[0]

0 commit comments

Comments
 (0)