Skip to content

Commit

Permalink
tests: Add regression for v1.13.1 pane spacing issue
Browse files Browse the repository at this point in the history
  • Loading branch information
tony committed Sep 10, 2022
1 parent 2b75fb2 commit f45a6f8
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
session_name: many-windows-issue
windows:
- window_name: moo
layout: main-horizontal
panes:
- echo hello
- echo hello
- echo hello
- echo hello
- echo hello
- echo hello
- echo hello
43 changes: 42 additions & 1 deletion tests/test_workspacebuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,26 @@
import pathlib
import textwrap
import time
import typing as t

import pytest

import kaptan

import libtmux
from libtmux import Window
from libtmux.common import has_gte_version, has_lt_version
from libtmux.test import retry_until, temp_session
from libtmux.window import Window
from tmuxp import config, exc
from tmuxp.cli.load import load_plugins
from tmuxp.workspacebuilder import WorkspaceBuilder

from .constants import EXAMPLE_PATH, FIXTURE_PATH
from .fixtures import utils as test_utils

if t.TYPE_CHECKING:
from libtmux.server import Server


def test_split_windows(session):
yaml_config = test_utils.read_config_file("workspacebuilder/two_pane.yaml")
Expand Down Expand Up @@ -1217,3 +1221,40 @@ def is_almost_equal(x, y):

assert is_almost_equal(height(panes[0]), height(panes[1]))
assert is_almost_equal(width(panes[0]), width(panes[1]))


def test_issue_800_default_size_many_windows(
server: "Server", monkeypatch: pytest.MonkeyPatch
) -> None:
"""Recreate default-size issue.
v1.13.1 added a default-size, but this can break building workspaces with
a lot of panes.
See also: https://github.com/tmux-python/tmuxp/issues/800
"""
yaml_config = test_utils.read_config_file(
"regressions/issue_800_default_size_many_windows.yaml"
)
sconfig = kaptan.Kaptan(handler="yaml")
sconfig = sconfig.import_config(yaml_config).get()
sconfig = config.expand(sconfig)
sconfig = config.trickle(sconfig)

builder = WorkspaceBuilder(sconf=sconfig, server=server)

with pytest.raises(libtmux.exc.LibTmuxException, match="no space for new pane"):
builder.build()

assert len(server.list_sessions()) == 1

# Assign an active pane to the session
second_session = server.list_sessions()[0]
first_pane_on_second_session_id = second_session.list_windows()[0].list_panes()[0][
"pane_id"
]
monkeypatch.setenv("TMUX_PANE", first_pane_on_second_session_id)

builder = WorkspaceBuilder(sconf=sconfig, server=server)

assert builder.find_current_attached_session() == second_session

0 comments on commit f45a6f8

Please sign in to comment.