From 2d0ff00c020fb0aae214df10949c6160218ef76c Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Mon, 26 Dec 2022 11:12:29 -0600 Subject: [PATCH 1/2] test(automatic rename): Fix renaming --- .../builder/window_automatic_rename.yaml | 4 +- tests/workspace/test_builder.py | 49 +++++++------------ 2 files changed, 22 insertions(+), 31 deletions(-) diff --git a/tests/fixtures/workspace/builder/window_automatic_rename.yaml b/tests/fixtures/workspace/builder/window_automatic_rename.yaml index a3640f4dedc..2584363930e 100644 --- a/tests/fixtures/workspace/builder/window_automatic_rename.yaml +++ b/tests/fixtures/workspace/builder/window_automatic_rename.yaml @@ -1,13 +1,15 @@ session_name: test window options start_directory: '~' windows: -- layout: main-horizontal +- window_name: renamed_window + layout: main-horizontal options: automatic-rename: on panes: - shell_command: - cmd: man ls start_directory: '~' + focus: true - shell_command: - cmd: echo "hey" - shell_command: diff --git a/tests/workspace/test_builder.py b/tests/workspace/test_builder.py index 331e24f2aa9..90ee02e18bd 100644 --- a/tests/workspace/test_builder.py +++ b/tests/workspace/test_builder.py @@ -415,15 +415,17 @@ def test_environment_variables_logs(session: Session, caplog: pytest.LogCaptureF sum( 1 for record in caplog.records - if 'Cannot set environment for new panes and windows.' in record.msg + if "Cannot set environment for new panes and windows." in record.msg ) # From both_overrides_in_first_pane. == 1 ) -def test_automatic_rename_option(session): - """With option automatic-rename: on.""" +def test_automatic_rename_option( + server: "Server", monkeypatch: pytest.MonkeyPatch +) -> None: + monkeypatch.setenv("DISABLE_AUTO_TITLE", "true") workspace = ConfigReader._from_file( test_utils.get_workspace_file("workspace/builder/window_automatic_rename.yaml") ) @@ -434,42 +436,29 @@ def test_automatic_rename_option(session): if " " in portable_command: portable_command = portable_command.split(" ")[0] - builder = WorkspaceBuilder(sconf=workspace) - - window_count = len(session._windows) # current window count - assert len(session._windows) == window_count - for w, wconf in builder.iter_create_windows(session): - - for p in builder.iter_create_panes(w, wconf): - w.select_layout("tiled") # fix glitch with pane size - p = p - assert len(session._windows), window_count - assert isinstance(w, Window) - assert w.show_window_option("automatic-rename") == "on" - - assert len(session._windows) == window_count - - window_count += 1 - w.select_layout(wconf["layout"]) + builder = WorkspaceBuilder(sconf=workspace, server=server) + builder.build() + session: Session = builder.session + w: Window = session.windows[0] + assert len(session.windows) == 1 - assert session.name != "tmuxp" - w = session.windows[0] + assert w.name != "renamed_window" def check_window_name_mismatch() -> bool: - session.server._update_windows() + w.server._update_windows() return w.name != portable_command - assert retry_until(check_window_name_mismatch, 2, interval=0.25) - - pane_base_index = w.show_window_option("pane-base-index", g=True) - w.select_pane(pane_base_index) + assert retry_until(check_window_name_mismatch, 5, interval=0.25) def check_window_name_match() -> bool: - session.server._update_windows() - return w.name == portable_command + w.server._update_windows() + assert w.show_window_option("automatic-rename") == "on" + + print(f"w.name: {w.name} and portable_command: {portable_command}") + return w.name == "zsh" or w.name == portable_command assert retry_until( - check_window_name_match, 2, interval=0.25 + check_window_name_match, 4, interval=0.05 ), f"Window name {w.name} should be {portable_command}" w.select_pane("-D") From 35c3e28b2b8229f03b82570435ee265c605720dc Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Mon, 26 Dec 2022 11:42:28 -0600 Subject: [PATCH 2/2] docs(CHANGES): Fix for automatic rename test --- CHANGES | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES b/CHANGES index 442d2011ded..79c8901cafc 100644 --- a/CHANGES +++ b/CHANGES @@ -19,6 +19,10 @@ $ pipx install --suffix=@next 'tmuxp' --pip-args '\--pre' --force +### Developmental + +- Tests: Stabilization fix for automatic rename test (#853) + ## tmuxp 1.19.1 (2022-12-12) ### Fixes