Skip to content

Commit f973b05

Browse files
committed
tests(automatic rename): Fix timeout check, use config's shell command name
Per tmux-python/libtmux#368, retry(seconds=...) is broke.
1 parent c768be0 commit f973b05

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

tests/test_workspacebuilder.py

+21-10
Original file line numberDiff line numberDiff line change
@@ -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,36 @@ def test_automatic_rename_option(session):
380386
assert s.name != "tmuxp"
381387
w = s.windows[0]
382388

383-
while retry():
389+
t = time.process_time()
390+
while (time.process_time() - t) * 1000 < 20:
384391
session.server._update_windows()
385-
if w.name != "sh":
392+
if w.name != portable_command:
386393
break
394+
time.sleep(0.2)
387395

388-
assert w.name != "sh"
396+
assert w.name != portable_command
389397

390398
pane_base_index = w.show_window_option("pane-base-index", g=True)
391399
w.select_pane(pane_base_index)
392400

393-
while retry():
401+
t = time.process_time()
402+
while (time.process_time() - t) * 1000 < 20:
394403
session.server._update_windows()
395-
if w.name == "sh":
404+
if w.name == portable_command:
396405
break
406+
time.sleep(0.2)
397407

398-
assert w.name == "sh"
408+
assert w.name == portable_command
399409

400410
w.select_pane("-D")
401411

402-
while retry():
412+
t = time.process_time()
413+
while (time.process_time() - t) * 1000 < 20:
403414
session.server._update_windows()
404-
if w["window_name"] != "sh":
415+
if w["window_name"] != portable_command:
405416
break
406-
407-
assert w.name != "sh"
417+
time.sleep(0.2)
418+
assert w.name != portable_command
408419

409420

410421
def test_blank_pane_count(session):

0 commit comments

Comments
 (0)