From 02cfedd07f3d37db3b8bf81437125b9fc8ffe85b Mon Sep 17 00:00:00 2001 From: Bjoern Hiller Date: Mon, 31 Oct 2022 08:21:47 +0100 Subject: [PATCH 1/3] fix(load): passthru of tmux config_file f93179d9a6af8624ed98c44a5a8582b1c05c9f99 erroneously renamed the argument for `libtmux.server.Server` which is still called `config_file`. --- src/tmuxp/cli/load.py | 4 ++-- tests/fixtures/tmux/tmux.conf | 1 + tests/test_cli.py | 25 +++++++++++++++++++++++-- 3 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 tests/fixtures/tmux/tmux.conf 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..8750e24876d 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=FIXTURE_PATH / "tmux" / "tmux.conf", + detached=True, + ) + + assert isinstance(session, Session) + assert isinstance(session.server, Server) + assert session.server.config_file == FIXTURE_PATH / "tmux" / "tmux.conf" + + def test_load_workspace_named_session( server: "Server", monkeypatch: pytest.MonkeyPatch ) -> None: From 0e10015c6ebc0efd19e9651deaeed686885a55b5 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Mon, 31 Oct 2022 07:05:51 -0500 Subject: [PATCH 2/3] chore: Temporarily use str until libtmux supports pathlib.Path --- tests/test_cli.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_cli.py b/tests/test_cli.py index 8750e24876d..4d1f8d89546 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -92,13 +92,13 @@ def test_load_workspace_passes_tmux_config( session = load_workspace( session_file, socket_name=server.socket_name, - tmux_config_file=FIXTURE_PATH / "tmux" / "tmux.conf", + 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 == FIXTURE_PATH / "tmux" / "tmux.conf" + assert session.server.config_file == str(FIXTURE_PATH / "tmux" / "tmux.conf") def test_load_workspace_named_session( From ab8e7762dbf41f85269ba6f04c44a4a6f732de64 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Mon, 31 Oct 2022 07:03:31 -0500 Subject: [PATCH 3/3] docs(CHANGES): Note bug fix for pass through --- CHANGES | 4 ++++ 1 file changed, 4 insertions(+) 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.