1111import libtmux
1212from libtmux import Window
1313from libtmux .common import has_gte_version
14- from libtmux .test import retry , temp_session
14+ from libtmux .test import retry , retry_until , temp_session
1515from tmuxp import config , exc
1616from tmuxp .cli .load import load_plugins
1717from 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
410409def test_blank_pane_count (session ):
0 commit comments