mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2026-01-01 08:10:09 +01:00
scanner: add tests for the extra data arguments
Fixed in !218, let's test this so we don't break it again.
This commit is contained in:
parent
3a9eb2d8b6
commit
00226da59e
3 changed files with 48 additions and 6 deletions
|
|
@ -38,9 +38,9 @@ variables:
|
|||
# See the documentation here: #
|
||||
# https://wayland.freedesktop.org/libinput/doc/latest/building_libinput.html #
|
||||
###############################################################################
|
||||
FEDORA_PACKAGES: 'git diffutils gcc gcc-c++ pkgconf-pkg-config systemd-devel libxkbcommon-devel libxml2 doxygen python3-attrs python3-pytest python3-dbusmock python3-jinja2 python3-pip hugo libabigail '
|
||||
FEDORA_PACKAGES: 'git diffutils gcc gcc-c++ pkgconf-pkg-config systemd-devel libxkbcommon-devel libxml2 doxygen python3-attrs python3-pytest python3-dbusmock python3-jinja2 python3-pip python3-pyyaml hugo libabigail '
|
||||
FEDORA_PIP_PACKAGES: 'meson ninja structlog strenum '
|
||||
DEBIAN_PACKAGES: 'git gcc g++ pkg-config libsystemd-dev libxkbcommon-dev libxml2 doxygen python3-attr python3-pytest python3-dbusmock python3-jinja2 python3-pip '
|
||||
DEBIAN_PACKAGES: 'git gcc g++ pkg-config libsystemd-dev libxkbcommon-dev libxml2 doxygen python3-attr python3-pytest python3-dbusmock python3-jinja2 python3-pip python3-yaml '
|
||||
DEBIAN_PIP_PACKAGES: 'meson ninja structlog strenum '
|
||||
############################ end of package lists #############################
|
||||
|
||||
|
|
@ -48,8 +48,8 @@ variables:
|
|||
# changing these will force rebuilding the associated image
|
||||
# Note: these tags have no meaning and are not tied to a particular
|
||||
# libinput version
|
||||
FEDORA_TAG: '2023-05-18.3'
|
||||
DEBIAN_TAG: '2023-05-18.3'
|
||||
FEDORA_TAG: '2023-05-25.0'
|
||||
DEBIAN_TAG: '2023-05-25.0'
|
||||
|
||||
FDO_UPSTREAM_REPO: libinput/libei
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
|
||||
# We're happy to rebuild all containers when one changes.
|
||||
.default_tag: &default_tag '2023-05-18.3'
|
||||
.default_tag: &default_tag '2023-05-25.0'
|
||||
|
||||
last_abi_break: 0.99.1
|
||||
minimum_meson_version: 0.56.0
|
||||
|
|
@ -29,6 +29,7 @@ distributions:
|
|||
- python3-dbusmock
|
||||
- python3-jinja2
|
||||
- python3-pip
|
||||
- python3-pyyaml
|
||||
- hugo # for documentation only
|
||||
- libabigail # for abidiff only
|
||||
pips:
|
||||
|
|
@ -54,6 +55,7 @@ distributions:
|
|||
- python3-dbusmock
|
||||
- python3-jinja2
|
||||
- python3-pip
|
||||
- python3-yaml
|
||||
pips:
|
||||
- meson
|
||||
- ninja
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
import pytest
|
||||
|
||||
try:
|
||||
from eiscanner import parse, Protocol
|
||||
from eiscanner import parse, scanner, Protocol
|
||||
except ImportError:
|
||||
print("Run tests from within the build directory")
|
||||
pytest.skip(allow_module_level=True)
|
||||
|
|
@ -44,3 +44,43 @@ class TestScanner:
|
|||
assert "handshake" in [i.plainname for i in protocol.interfaces]
|
||||
assert "connection" in [i.plainname for i in protocol.interfaces]
|
||||
assert "button" in [i.plainname for i in protocol.interfaces]
|
||||
|
||||
@pytest.mark.parametrize("method", ("yamlfile", "jsonfile", "string"))
|
||||
def test_cli_extra_data(self, tmp_path, method):
|
||||
result_path = tmp_path / "result"
|
||||
tmpl_path = tmp_path / "template"
|
||||
with open(tmpl_path, "w") as template:
|
||||
template.write(">{{extra.foo}}<")
|
||||
|
||||
if method == "yamlfile":
|
||||
extra_path = tmp_path / "extra_data.yml"
|
||||
with open(extra_path, "w") as extra_data:
|
||||
extra_data.write("foo: 'yes'")
|
||||
extra_data_arg = f"--jinja-extra-data-file={extra_path}"
|
||||
elif method == "jsonfile":
|
||||
extra_path = tmp_path / "extra_data.json"
|
||||
with open(extra_path, "w") as extra_data:
|
||||
extra_data.write('{"foo": "yes"}')
|
||||
extra_data_arg = f"--jinja-extra-data-file={extra_path}"
|
||||
elif method == "string":
|
||||
extra_data = '{"foo": "yes"}'
|
||||
extra_data_arg = f"--jinja-extra-data={extra_data}"
|
||||
else:
|
||||
pytest.fail(f"Unsupported method {method}")
|
||||
|
||||
try:
|
||||
scanner(
|
||||
[
|
||||
f"--output={result_path}",
|
||||
extra_data_arg,
|
||||
protofile,
|
||||
str(tmpl_path),
|
||||
]
|
||||
)
|
||||
except SystemExit as e:
|
||||
pytest.fail(reason=f"Unexpected system exit code {e}")
|
||||
|
||||
assert result_path.exists()
|
||||
with open(result_path) as fd:
|
||||
result = fd.read()
|
||||
assert result == ">yes<"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue