Skip to content

Commit 4435de4

Browse files
authored
test: Fix automatic rename (#774)
Fixes #620
2 parents c768be0 + 23face2 commit 4435de4

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

tests/fixtures/workspacebuilder/window_automatic_rename.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ windows:
66
automatic-rename: on
77
panes:
88
- shell_command:
9-
- cmd: sh
9+
- cmd: man ls
1010
start_directory: '~'
1111
- shell_command:
1212
- cmd: echo "hey"

tests/test_workspacebuilder.py

+14-15
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import libtmux
1212
from libtmux import Window
1313
from libtmux.common import has_gte_version
14-
from libtmux.test import retry, temp_session
14+
from libtmux.test import retry, retry_until, temp_session
1515
from tmuxp import config, exc
1616
from tmuxp.cli.load import load_plugins
1717
from tmuxp.workspacebuilder import WorkspaceBuilder
@@ -359,6 +359,12 @@ def test_automatic_rename_option(session):
359359
sconfig = kaptan.Kaptan(handler="yaml")
360360
sconfig = sconfig.import_config(yaml_config).get()
361361

362+
# This should be a command guaranteed to be terminal name across systems
363+
portable_command = sconfig["windows"][0]["panes"][0]["shell_command"][0]["cmd"]
364+
# If a command is like "man ls", get the command base name, "ls"
365+
if " " in portable_command:
366+
portable_command = portable_command.split(" ")[0]
367+
362368
builder = WorkspaceBuilder(sconf=sconfig)
363369

364370
window_count = len(session._windows) # current window count
@@ -380,31 +386,24 @@ def test_automatic_rename_option(session):
380386
assert s.name != "tmuxp"
381387
w = s.windows[0]
382388

383-
while retry():
389+
def check_window_name_mismatch() -> bool:
384390
session.server._update_windows()
385-
if w.name != "sh":
386-
break
391+
return w.name != portable_command
387392

388-
assert w.name != "sh"
393+
assert retry_until(check_window_name_mismatch, 2, interval=0.25)
389394

390395
pane_base_index = w.show_window_option("pane-base-index", g=True)
391396
w.select_pane(pane_base_index)
392397

393-
while retry():
398+
def check_window_name_match() -> bool:
394399
session.server._update_windows()
395-
if w.name == "sh":
396-
break
400+
return w.name == portable_command
397401

398-
assert w.name == "sh"
402+
assert retry_until(check_window_name_match, 2, interval=0.25)
399403

400404
w.select_pane("-D")
401405

402-
while retry():
403-
session.server._update_windows()
404-
if w["window_name"] != "sh":
405-
break
406-
407-
assert w.name != "sh"
406+
assert retry_until(check_window_name_mismatch, 2, interval=0.25)
408407

409408

410409
def test_blank_pane_count(session):

0 commit comments

Comments
 (0)