Skip to content

Commit 4a05ee5

Browse files
committed
tests: Add regression for v1.13.1 pane spacing issue
1 parent 2b75fb2 commit 4a05ee5

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
session_name: many-windows-issue
2+
windows:
3+
- window_name: moo
4+
layout: main-horizontal
5+
panes:
6+
- echo hello
7+
- echo hello
8+
- echo hello
9+
- echo hello
10+
- echo hello
11+
- echo hello
12+
- echo hello

tests/test_workspacebuilder.py

+40
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import pathlib
44
import textwrap
55
import time
6+
import typing as t
67

78
import pytest
89

@@ -11,6 +12,7 @@
1112
import libtmux
1213
from libtmux import Window
1314
from libtmux.common import has_gte_version, has_lt_version
15+
from libtmux.exc import LibTmuxException
1416
from libtmux.test import retry_until, temp_session
1517
from tmuxp import config, exc
1618
from tmuxp.cli.load import load_plugins
@@ -19,6 +21,9 @@
1921
from .constants import EXAMPLE_PATH, FIXTURE_PATH
2022
from .fixtures import utils as test_utils
2123

24+
if t.TYPE_CHECKING:
25+
from libtmux.server import Server
26+
2227

2328
def test_split_windows(session):
2429
yaml_config = test_utils.read_config_file("workspacebuilder/two_pane.yaml")
@@ -1217,3 +1222,38 @@ def is_almost_equal(x, y):
12171222

12181223
assert is_almost_equal(height(panes[0]), height(panes[1]))
12191224
assert is_almost_equal(width(panes[0]), width(panes[1]))
1225+
1226+
1227+
def test_issue_800_default_size_many_windows(
1228+
server: "Server", monkeypatch: pytest.MonkeyPatch
1229+
) -> None:
1230+
"""Recreate default-size issue.
1231+
1232+
v1.13.1 added a default-size, but this can break building workspaces with
1233+
a lot of panes.
1234+
"""
1235+
yaml_config = test_utils.read_config_file(
1236+
"regressions/issue_800_default_size_many_windows.yaml"
1237+
)
1238+
sconfig = kaptan.Kaptan(handler="yaml")
1239+
sconfig = sconfig.import_config(yaml_config).get()
1240+
sconfig = config.expand(sconfig)
1241+
sconfig = config.trickle(sconfig)
1242+
1243+
builder = WorkspaceBuilder(sconf=sconfig, server=server)
1244+
1245+
with pytest.raises(libtmux.exc.LibTmuxException, match="no space for new pane"):
1246+
builder.build()
1247+
1248+
assert len(server.list_sessions()) == 1
1249+
1250+
# Assign an active pane to the session
1251+
second_session = server.list_sessions()[0]
1252+
first_pane_on_second_session_id = second_session.list_windows()[0].list_panes()[0][
1253+
"pane_id"
1254+
]
1255+
monkeypatch.setenv("TMUX_PANE", first_pane_on_second_session_id)
1256+
1257+
builder = WorkspaceBuilder(sconf=sconfig, server=server)
1258+
1259+
assert builder.find_current_attached_session() == second_session

0 commit comments

Comments
 (0)