diff --git a/CHANGES b/CHANGES index 0600fe35125..33d73ca468f 100644 --- a/CHANGES +++ b/CHANGES @@ -21,6 +21,10 @@ $ pipx install --suffix=@next 'tmuxp' --pip-args '\--pre' --force +### Bug fix + +- cli: `tmuxp load`: Fix pass-through of config files (#843) + ## tmuxp 1.18.0 (2022-10-30) We now refer to configs as workspaces. Other than just, just maintenance. diff --git a/src/tmuxp/cli/load.py b/src/tmuxp/cli/load.py index 6443bcb05f0..945463fc3f4 100644 --- a/src/tmuxp/cli/load.py +++ b/src/tmuxp/cli/load.py @@ -254,7 +254,7 @@ def load_workspace( workspace_file: StrPath, socket_name: t.Optional[str] = None, socket_path: None = None, - tmux_config_file: None = None, + tmux_config_file: t.Optional[str] = None, new_session_name: t.Optional[str] = None, colors: t.Optional[int] = None, detached: bool = False, @@ -382,7 +382,7 @@ def load_workspace( t = Server( # create tmux server object socket_name=socket_name, socket_path=socket_path, - workspace_file=tmux_config_file, + config_file=tmux_config_file, colors=colors, ) diff --git a/tests/fixtures/tmux/tmux.conf b/tests/fixtures/tmux/tmux.conf new file mode 100644 index 00000000000..ed2abd7ef9f --- /dev/null +++ b/tests/fixtures/tmux/tmux.conf @@ -0,0 +1 @@ +display-message "Hello World" diff --git a/tests/test_cli.py b/tests/test_cli.py index 7e4651572a1..4d1f8d89546 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -13,6 +13,7 @@ import libtmux from libtmux.common import has_lt_version from libtmux.exc import LibTmuxException +from libtmux.server import Server from libtmux.session import Session from tmuxp import cli, exc from tmuxp.cli.import_config import get_teamocil_dir, get_tmuxinator_dir @@ -35,8 +36,6 @@ if t.TYPE_CHECKING: import _pytest.capture - from libtmux.server import Server - def test_creates_config_dir_not_exists(tmp_path: pathlib.Path) -> None: """cli.startup() creates config dir if not exists.""" @@ -80,6 +79,28 @@ def test_load_workspace(server: "Server", monkeypatch: pytest.MonkeyPatch) -> No assert session.name == "sample workspace" +def test_load_workspace_passes_tmux_config( + server: "Server", monkeypatch: pytest.MonkeyPatch +) -> None: + # this is an implementation test. Since this testsuite may be ran within + # a tmux session by the developer himself, delete the TMUX variable + # temporarily. + monkeypatch.delenv("TMUX", raising=False) + session_file = FIXTURE_PATH / "workspace/builder" / "two_pane.yaml" + + # open it detached + session = load_workspace( + session_file, + socket_name=server.socket_name, + tmux_config_file=str(FIXTURE_PATH / "tmux" / "tmux.conf"), + detached=True, + ) + + assert isinstance(session, Session) + assert isinstance(session.server, Server) + assert session.server.config_file == str(FIXTURE_PATH / "tmux" / "tmux.conf") + + def test_load_workspace_named_session( server: "Server", monkeypatch: pytest.MonkeyPatch ) -> None: