Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 26 additions & 6 deletions tests/test_tmx.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import socket
import subprocess
import tempfile
import time
from pathlib import Path
from typing import NoReturn

Expand Down Expand Up @@ -153,17 +154,36 @@ def test_directory_names_are_distinct_and_do_not_expand_tmux_formats(
assert tmx.main([str(directory)]) == 0
name = "tmx" + str(tmp_path.resolve()) + "/" + encoded
assert connections[-1][1][-1] == "=" + name
result = tmux_server(
target = "=" + name + ":"
# tmux reads the pane's directory from its process, which may not have started yet.
deadline = time.monotonic() + 5
while True:
result = tmux_server(
"display-message",
"-p",
"-t",
target,
"#{pane_current_path}",
capture_output=True,
text=True,
)
if result.stdout.strip() == str(directory.resolve()) or time.monotonic() > deadline:
break
time.sleep(0.05)
assert result.returncode == 0, result.stderr
diagnostics = tmux_server(
"display-message",
"-p",
"-t",
"=" + name + ":",
"#{pane_current_path}",
target,
"start=#{pane_start_path} pid=#{pane_pid} cmd=#{pane_current_command}",
capture_output=True,
text=True,
)
assert result.returncode == 0, result.stderr
assert result.stdout.strip() == str(directory.resolve())
).stdout.strip()
pid = diagnostics.split("pid=")[1].split()[0]
proc = Path(f"/proc/{pid}")
proc_cwd = (proc / "cwd").readlink() if proc.exists() else "?"
assert result.stdout.strip() == str(directory.resolve()), f"{diagnostics} cwd={proc_cwd}"
result = tmux_server("list-sessions", "-F", "#{session_name}", capture_output=True, text=True)
assert len(result.stdout.splitlines()) == 5

Expand Down
Loading