mirror of
https://github.com/X11Libre/xserver.git
synced 2026-11-23 06:43:07 +00:00
test/pyxtest: allow for extra arguments in the xserver fixture
This allows tests to use an xserver_args fixture/parameter to pass arguments for the xserver fixture they may use. Assisted-by: Claude:claude-opus-4-6 Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2263> Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
ca2b7f19fc
commit
dc9bec79cd
2 changed files with 46 additions and 9 deletions
|
|
@ -516,6 +516,14 @@ ddxProcessArgument(int argc, char *argv[], int i)
|
|||
return 2;
|
||||
}
|
||||
|
||||
if (strcmp(argv[i], "+fontserverconnections") == 0) {
|
||||
enableFontServerConnections = true;
|
||||
return 1;
|
||||
}
|
||||
if (strcmp(argv[i], "-fontserverconnections") == 0) {
|
||||
enableFontServerConnections = false;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -228,7 +228,7 @@ def _persist_valgrind_report(request, server_type, xml_path, errors):
|
|||
)
|
||||
|
||||
|
||||
def _start_server(request, server_type, log_file=None):
|
||||
def _start_server(request, server_type, extra_args=None, log_file=None):
|
||||
"""Start an X server of the given type for a test.
|
||||
|
||||
Shared implementation for the xvfb, xwayland, xorg, and generic
|
||||
|
|
@ -257,6 +257,7 @@ def _start_server(request, server_type, log_file=None):
|
|||
valgrind_suppressions=suppressions,
|
||||
asan=use_asan,
|
||||
server_path=server_path,
|
||||
extra_args=extra_args,
|
||||
log_file=log_file,
|
||||
)
|
||||
|
||||
|
|
@ -307,7 +308,30 @@ def _start_server(request, server_type, log_file=None):
|
|||
|
||||
|
||||
@pytest.fixture
|
||||
def xserver(request, tmp_path):
|
||||
def xserver_args():
|
||||
"""Extra command-line arguments for the X server fixtures.
|
||||
|
||||
Override this fixture in test files (or test classes) to pass
|
||||
extra arguments to the X server. The default is an empty list.
|
||||
The ``xserver``, ``xvfb``, ``xwayland``, and ``xorg`` fixtures
|
||||
all pass these arguments through to the server process.
|
||||
|
||||
Example::
|
||||
|
||||
@pytest.fixture(params=["enabled", "disabled"])
|
||||
def xserver_args(request):
|
||||
if request.param == "enabled":
|
||||
return ["+byteswappedclients"]
|
||||
return ["-byteswappedclients"]
|
||||
|
||||
def test_something(xserver, xclient):
|
||||
...
|
||||
"""
|
||||
return []
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def xserver(request, tmp_path, xserver_args):
|
||||
"""
|
||||
Start an X server for this test.
|
||||
|
||||
|
|
@ -316,6 +340,9 @@ def xserver(request, tmp_path):
|
|||
A fresh server per test, killed afterward. With --valgrind,
|
||||
valgrind memory errors cause test failure during teardown.
|
||||
|
||||
Extra command-line arguments can be passed by overriding the
|
||||
:func:`xserver_args` fixture.
|
||||
|
||||
When ``--display`` is given, no server is started; an
|
||||
:class:`ExternalXServer` proxy is yielded instead.
|
||||
|
||||
|
|
@ -341,11 +368,11 @@ def xserver(request, tmp_path):
|
|||
if server_type == "xorg":
|
||||
kwargs["log_file"] = tmp_path / f"{server_type}.log"
|
||||
|
||||
yield from _start_server(request, server_type, **kwargs)
|
||||
yield from _start_server(request, server_type, extra_args=xserver_args, **kwargs)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def xvfb(request, tmp_path):
|
||||
def xvfb(request, tmp_path, xserver_args):
|
||||
"""Start an Xvfb server for this test."""
|
||||
display = request.config.getoption("--display")
|
||||
if display is not None:
|
||||
|
|
@ -353,11 +380,11 @@ def xvfb(request, tmp_path):
|
|||
return
|
||||
if "xvfb" not in get_server_types(request.config):
|
||||
pytest.skip("Xvfb not in --server-type list")
|
||||
yield from _start_server(request, "xvfb")
|
||||
yield from _start_server(request, "xvfb", extra_args=xserver_args)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def xwayland(request, tmp_path):
|
||||
def xwayland(request, tmp_path, xserver_args):
|
||||
"""Start an Xwayland server for this test."""
|
||||
display = request.config.getoption("--display")
|
||||
if display is not None:
|
||||
|
|
@ -365,11 +392,11 @@ def xwayland(request, tmp_path):
|
|||
return
|
||||
if "xwayland" not in get_server_types(request.config):
|
||||
pytest.skip("Xwayland not in --server-type list")
|
||||
yield from _start_server(request, "xwayland")
|
||||
yield from _start_server(request, "xwayland", extra_args=xserver_args)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def xorg(request, tmp_path):
|
||||
def xorg(request, tmp_path, xserver_args):
|
||||
"""Start an Xorg server for this test."""
|
||||
display = request.config.getoption("--display")
|
||||
if display is not None:
|
||||
|
|
@ -377,7 +404,9 @@ def xorg(request, tmp_path):
|
|||
return
|
||||
if "xorg" not in get_server_types(request.config):
|
||||
pytest.skip("Xorg not in --server-type list")
|
||||
yield from _start_server(request, "xorg", log_file=tmp_path / "xorg.log")
|
||||
yield from _start_server(
|
||||
request, "xorg", log_file=tmp_path / "xorg.log", extra_args=xserver_args
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
|
|
|||
Loading…
Reference in a new issue