Skip to content

Commit

Permalink
tests(automatic rename): Fix timeout check, use config's shell comman…
Browse files Browse the repository at this point in the history
…d name

Per tmux-python/libtmux#368, retry(seconds=...)
is broke.
  • Loading branch information
tony committed May 21, 2022
1 parent c768be0 commit f973b05
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions tests/test_workspacebuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,12 @@ def test_automatic_rename_option(session):
sconfig = kaptan.Kaptan(handler="yaml")
sconfig = sconfig.import_config(yaml_config).get()

# This should be a command guaranteed to be terminal name across systems
portable_command = sconfig["windows"][0]["panes"][0]["shell_command"][0]["cmd"]
# If a command is like "man ls", get the command base name, "ls"
if " " in portable_command:
portable_command = portable_command.split(" ")[0]

builder = WorkspaceBuilder(sconf=sconfig)

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

while retry():
t = time.process_time()
while (time.process_time() - t) * 1000 < 20:
session.server._update_windows()
if w.name != "sh":
if w.name != portable_command:
break
time.sleep(0.2)

assert w.name != "sh"
assert w.name != portable_command

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

while retry():
t = time.process_time()
while (time.process_time() - t) * 1000 < 20:
session.server._update_windows()
if w.name == "sh":
if w.name == portable_command:
break
time.sleep(0.2)

assert w.name == "sh"
assert w.name == portable_command

w.select_pane("-D")

while retry():
t = time.process_time()
while (time.process_time() - t) * 1000 < 20:
session.server._update_windows()
if w["window_name"] != "sh":
if w["window_name"] != portable_command:
break

assert w.name != "sh"
time.sleep(0.2)
assert w.name != portable_command


def test_blank_pane_count(session):
Expand Down

0 comments on commit f973b05

Please sign in to comment.