Skip to content

Commit b975b3f

Browse files
committed
test(control-mode): Add xfail coverage for backlog, notifications, collisions
1 parent 55d2a30 commit b975b3f

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

tests/test_control_mode_engine.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,3 +334,39 @@ def test_run_result_retries_after_broken_pipe(
334334
# TODO: Implement retry simulation when engine supports injectable I/O.
335335
with pytest.raises(exc.ControlModeConnectionError):
336336
engine.run("list-sessions")
337+
338+
339+
class BackpressureFixture(t.NamedTuple):
340+
"""Fixture for notification backpressure integration."""
341+
342+
test_id: str
343+
queue_size: int
344+
overflow: int
345+
expect_iter: bool
346+
347+
348+
@pytest.mark.xfail(
349+
reason="control-mode notification backpressure integration not stable yet",
350+
strict=False,
351+
)
352+
@pytest.mark.parametrize(
353+
"case",
354+
[
355+
BackpressureFixture(
356+
test_id="notif_overflow_iter",
357+
queue_size=1,
358+
overflow=5,
359+
expect_iter=True,
360+
),
361+
],
362+
ids=lambda c: c.test_id,
363+
)
364+
def test_notifications_overflow_then_iter(case: BackpressureFixture) -> None:
365+
"""Flood notif queue then ensure iter_notifications still yields."""
366+
engine = ControlModeEngine()
367+
engine._protocol = ControlProtocol(notification_queue_size=case.queue_size)
368+
for _ in range(case.overflow):
369+
engine._protocol.feed_line("%sessions-changed")
370+
if case.expect_iter:
371+
notif = next(engine.iter_notifications(timeout=0.05), None)
372+
assert notif is not None

tests/test_control_mode_regressions.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,3 +767,29 @@ def test_attach_to_existing_session(case: AttachFixture) -> None:
767767
finally:
768768
with contextlib.suppress(Exception):
769769
bootstrap.kill()
770+
771+
772+
@pytest.mark.engines(["control"])
773+
@pytest.mark.xfail(
774+
reason="list-clients filtering vs attached_sessions needs stable control flag",
775+
strict=False,
776+
)
777+
def test_list_clients_control_flag_filters_attached() -> None:
778+
"""Control client row should have C flag and be filtered from attached_sessions."""
779+
if has_lt_version("3.2"):
780+
pytest.skip("tmux < 3.2 omits client_flags")
781+
socket_name = f"libtmux_test_{uuid.uuid4().hex[:8]}"
782+
engine = ControlModeEngine()
783+
server = Server(socket_name=socket_name, engine=engine)
784+
try:
785+
_ = server.sessions # start control mode
786+
res = server.cmd(
787+
"list-clients",
788+
"-F",
789+
"#{client_pid} #{client_flags} #{session_name}",
790+
)
791+
assert any("C" in line.split()[1] for line in res.stdout)
792+
assert server.attached_sessions == []
793+
finally:
794+
with contextlib.suppress(Exception):
795+
server.kill()

0 commit comments

Comments
 (0)