Skip to content

Commit 32521e5

Browse files
committed
Hooks(chore[compat]): drop tmux<3.2 guards
why: libtmux now requires tmux 3.2+, so legacy compatibility paths add noise. what: - Remove has_lt_version checks in hooks helper - Delete <3.2 skips in control-mode/client log tests
1 parent a5f9a0b commit 32521e5

File tree

3 files changed

+7
-57
lines changed

3 files changed

+7
-57
lines changed

src/libtmux/hooks.py

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
Hooks,
3939
)
4040
from libtmux._internal.sparse_array import SparseArray
41-
from libtmux.common import CmdMixin, has_lt_version
41+
from libtmux.common import CmdMixin
4242
from libtmux.constants import (
4343
DEFAULT_OPTION_SCOPE,
4444
HOOK_SCOPE_FLAG_MAP,
@@ -89,13 +89,7 @@ def run_hook(
8989
assert scope in HOOK_SCOPE_FLAG_MAP
9090

9191
flag = HOOK_SCOPE_FLAG_MAP[scope]
92-
if flag in {"-p", "-w"} and has_lt_version("3.2"):
93-
warnings.warn(
94-
"Scope flag '-w' and '-p' requires tmux 3.2+. Ignoring.",
95-
stacklevel=2,
96-
)
97-
else:
98-
flags += (flag,)
92+
flags += (flag,)
9993

10094
cmd = self.cmd(
10195
"set-hook",
@@ -168,13 +162,7 @@ def set_hook(
168162
assert scope in HOOK_SCOPE_FLAG_MAP
169163

170164
flag = HOOK_SCOPE_FLAG_MAP[scope]
171-
if flag in {"-p", "-w"} and has_lt_version("3.2"):
172-
warnings.warn(
173-
"Scope flag '-w' and '-p' requires tmux 3.2+. Ignoring.",
174-
stacklevel=2,
175-
)
176-
else:
177-
flags += (flag,)
165+
flags += (flag,)
178166

179167
cmd = self.cmd(
180168
"set-hook",
@@ -221,13 +209,7 @@ def unset_hook(
221209
assert scope in HOOK_SCOPE_FLAG_MAP
222210

223211
flag = HOOK_SCOPE_FLAG_MAP[scope]
224-
if flag in {"-p", "-w"} and has_lt_version("3.2"):
225-
warnings.warn(
226-
"Scope flag '-w' and '-p' requires tmux 3.2+. Ignoring.",
227-
stacklevel=2,
228-
)
229-
else:
230-
flags += (flag,)
212+
flags += (flag,)
231213

232214
cmd = self.cmd(
233215
"set-hook",
@@ -286,13 +268,7 @@ def show_hooks(
286268
assert scope in HOOK_SCOPE_FLAG_MAP
287269

288270
flag = HOOK_SCOPE_FLAG_MAP[scope]
289-
if flag in {"-p", "-w"} and has_lt_version("3.2"):
290-
warnings.warn(
291-
"Scope flag '-w' and '-p' requires tmux 3.2+. Ignoring.",
292-
stacklevel=2,
293-
)
294-
else:
295-
flags += (flag,)
271+
flags += (flag,)
296272

297273
cmd = self.cmd("show-hooks", *flags)
298274
output = cmd.stdout
@@ -344,13 +320,7 @@ def _show_hook(
344320
assert scope in HOOK_SCOPE_FLAG_MAP
345321

346322
flag = HOOK_SCOPE_FLAG_MAP[scope]
347-
if flag in {"-p", "-w"} and has_lt_version("3.2"):
348-
warnings.warn(
349-
"Scope flag '-w' and '-p' requires tmux 3.2+. Ignoring.",
350-
stacklevel=2,
351-
)
352-
else:
353-
flags += (flag,)
323+
flags += (flag,)
354324

355325
flags += (hook,)
356326

tests/test_control_client_logs.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import pytest
88

99
from libtmux._internal.engines.control_protocol import CommandContext, ControlProtocol
10-
from libtmux.common import has_lt_version
1110

1211

1312
@pytest.mark.engines(["control"])
@@ -39,8 +38,6 @@ def test_control_client_lists_clients(
3938

4039
assert list_ctx.done.wait(timeout=0.5)
4140
result = proto.build_result(list_ctx)
42-
if has_lt_version("3.2"):
43-
pytest.xfail("tmux < 3.2 omits client_flags field in list-clients")
4441

4542
saw_control_flag = any(
4643
len(parts := line.split()) >= 2
@@ -105,8 +102,6 @@ def test_control_client_lists_control_flag(
105102
) -> None:
106103
"""list-clients should show control client with C flag on tmux >= 3.2."""
107104
proc, proto = control_client_logs
108-
if has_lt_version("3.2"):
109-
pytest.skip("tmux < 3.2 omits client_flags")
110105

111106
assert proc.stdin is not None
112107
list_ctx = CommandContext(

tests/test_control_mode_regressions.py

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
CommandContext,
1919
ControlProtocol,
2020
)
21-
from libtmux.common import has_lt_version
2221
from libtmux.server import Server
2322
from tests.helpers import wait_for_line
2423

@@ -239,17 +238,11 @@ def test_environment_propagation(case: EnvPropagationFixture) -> None:
239238
"""Environment vars should surface inside panes (tmux >= 3.2 for -e support).
240239
241240
Uses ``wait_for_line`` to allow control-mode capture to observe the shell
242-
output after send-keys; older tmux releases ignore ``-e`` and are skipped.
241+
output after send-keys.
243242
"""
244-
if has_lt_version("3.2"):
245-
pytest.skip("tmux < 3.2 ignores -e in this environment")
246-
247243
env = shutil.which("env")
248244
assert env is not None
249245

250-
if has_lt_version("3.2"):
251-
pytest.skip("tmux < 3.2 does not support -e on new-window/split")
252-
253246
socket_name = f"libtmux_test_{uuid.uuid4().hex[:8]}"
254247
engine = ControlModeEngine()
255248
server = Server(socket_name=socket_name, engine=engine)
@@ -533,15 +526,9 @@ class EnvMultiFixture(t.NamedTuple):
533526
@pytest.mark.parametrize("case", ENV_MULTI_CASES)
534527
def test_environment_multi_var_propagation(case: EnvMultiFixture) -> None:
535528
"""Multiple ``-e`` flags should all be delivered inside the pane (tmux >= 3.2)."""
536-
if has_lt_version("3.2"):
537-
pytest.skip("tmux < 3.2 ignores -e in this environment")
538-
539529
env = shutil.which("env")
540530
assert env is not None
541531

542-
if has_lt_version("3.2"):
543-
pytest.skip("tmux < 3.2 does not support -e on new-window")
544-
545532
socket_name = f"libtmux_test_{uuid.uuid4().hex[:8]}"
546533
engine = ControlModeEngine()
547534
server = Server(socket_name=socket_name, engine=engine)
@@ -837,8 +824,6 @@ def test_list_clients_control_flag_filters_attached() -> None:
837824
The engine's exclude_internal_sessions() method checks for this flag and
838825
filters control clients from attached_sessions.
839826
"""
840-
if has_lt_version("3.2"):
841-
pytest.skip("tmux < 3.2 omits client_flags")
842827
socket_name = f"libtmux_test_{uuid.uuid4().hex[:8]}"
843828
engine = ControlModeEngine()
844829
server = Server(socket_name=socket_name, engine=engine)

0 commit comments

Comments
 (0)