From 50f818fddbebf386bfe10aa32d9af632d6f15bca Mon Sep 17 00:00:00 2001 From: "Dennis K. Paulsen" Date: Wed, 30 Sep 2026 13:10:19 -0500 Subject: [PATCH] fix: skip the four loader tests that need a real C library and the three keymap tests that need memfd_create instead of failing collection off Linux, so the suite runs on Windows at 212 passed and 18 skipped, and correct the unbound gesture/stylus count in README.md and the architecture docs to 46 in libei and 51 in libeis against 1.6.0's headers --- CHANGELOG.md | 18 ++++++++++++++++++ README.md | 5 +++-- docs/developers/architecture.md | 6 ++++-- tests/test_ei_objects.py | 4 ++++ tests/test_eis_objects.py | 4 ++++ tests/test_integration_extras.py | 4 ++++ tests/test_loader.py | 15 ++++++++++++--- 7 files changed, 49 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7423aec..9ee725a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,24 @@ All notable changes to python-libei are recorded here. The format follows [semantic versioning](https://semver.org/spec/v2.0.0.html) — with the usual 0.x caveat that the API may still change between minor versions. +## [Unreleased] + +### Fixed + +- **The test suite ran nothing at all off Linux and FreeBSD.** `tests/test_loader.py` + raised at module level when `ctypes.util.find_library("c")` found no C library, + which pytest reports as a *collection* error -- so on Windows `pytest -q -rs` + stopped before any of the other 200-odd tests, including every pure-Python one. + The four loader tests that need a real library now skip there instead, and the + three tests that build a keymap with `os.memfd_create` skip where it does not + exist. On Windows the suite now reports 212 passed, 18 skipped; on Linux nothing + changes -- 230 passed against libei 1.6.0. +- **The count of unbound gesture/stylus functions was stale.** The README and + `docs/developers/architecture.md` said libei's `main` adds 22; counted against + 1.6.0's headers on 2026-09-30 it is 46 in libei and 51 in libeis, now that the + stylus protocol has landed there too. Still none of it is in a release, so still + none of it is bound. + ## [0.6.0] - 2026-09-22 ### Added diff --git a/README.md b/README.md index 5e618f7..de3af76 100644 --- a/README.md +++ b/README.md @@ -106,8 +106,9 @@ because a skimming reader could otherwise take them as supported. 1.6.0's own `enum ei_device_capability` stops at `TEXT`, and its `enum ei_event_type` stops at `EI_EVENT_TEXT_UTF8` — so the swipe/pinch/hold/stylus members of `EventType` cannot arrive either. The values here match upstream `main` -exactly, so they are ready for whatever release adds them. The 22 -gesture/stylus accessor functions `main` adds are deliberately not bound: +exactly, so they are ready for whatever release adds them. The gesture +and stylus functions `main` adds -- 46 in libei and 51 in libeis against +1.6.0's headers, counted 2026-09-30 -- are deliberately not bound: nothing that ships today exports them, so nothing here could be verified against a real library, which is the bar every other binding in this package was held to. diff --git a/docs/developers/architecture.md b/docs/developers/architecture.md index 409d134..8cf906d 100644 --- a/docs/developers/architecture.md +++ b/docs/developers/architecture.md @@ -55,8 +55,10 @@ deliberate: is only ever created by its own `create_for_*()`, never wrapped from a raw pointer. -The 22 gesture/stylus accessor functions that libei's `main` branch adds are -also unbound. Nothing that ships today exports them, so nothing here could be +The gesture and stylus functions that libei's `main` branch adds -- 46 in +libei and 51 in libeis against 1.6.0's headers, counted 2026-09-30: the +swipe, pinch and hold senders and event getters, and the whole stylus +protocol -- are also unbound. Nothing that ships today exports them, so nothing here could be verified against a real library — which is the bar every other binding in this package was held to. diff --git a/tests/test_ei_objects.py b/tests/test_ei_objects.py index f174ed2..1deafc5 100644 --- a/tests/test_ei_objects.py +++ b/tests/test_ei_objects.py @@ -735,6 +735,10 @@ def test_peek_event_type_is_none_on_an_empty_queue( assert ctx.peek_event_type() is None +@pytest.mark.skipif( + not hasattr(os, "memfd_create"), + reason="os.memfd_create is Linux/FreeBSD only", +) def test_keymap_fd_is_rewound(monkeypatch: pytest.MonkeyPatch) -> None: # dup(2) shares the file offset, and libei leaves its own fd at EOF -- # without a rewind the caller reads zero bytes and no error, which looks diff --git a/tests/test_eis_objects.py b/tests/test_eis_objects.py index 7b5dd7f..ea1c1bf 100644 --- a/tests/test_eis_objects.py +++ b/tests/test_eis_objects.py @@ -385,6 +385,10 @@ def test_region_mapping_id_round_trips(monkeypatch: pytest.MonkeyPatch) -> None: assert region.mapping_id == "screen-0" +@pytest.mark.skipif( + not hasattr(os, "memfd_create"), + reason="os.memfd_create is Linux/FreeBSD only", +) def test_keymap_fd_is_rewound(monkeypatch: pytest.MonkeyPatch) -> None: fd = os.memfd_create("keymap") try: diff --git a/tests/test_integration_extras.py b/tests/test_integration_extras.py index e82c133..a49ef6a 100644 --- a/tests/test_integration_extras.py +++ b/tests/test_integration_extras.py @@ -229,6 +229,10 @@ def on_client_event(event: ei.Event) -> None: assert pongs[0] == sent_id[0] +@pytest.mark.skipif( + not hasattr(os, "memfd_create"), + reason="os.memfd_create is Linux/FreeBSD only", +) def test_keymap_transfers_and_reads_back() -> None: keymap_text = b"xkb_keymap { /* test */ };\x00" source = os.memfd_create("test-keymap") diff --git a/tests/test_loader.py b/tests/test_loader.py index 93957c9..5427e70 100644 --- a/tests/test_loader.py +++ b/tests/test_loader.py @@ -18,9 +18,14 @@ from libei._capi.loader import LazyLibrary, LibraryNotFoundError _found_libc = util.find_library("c") -if _found_libc is None: - raise RuntimeError("no C library found -- these tests need one to stand in") -_LIBC: str = _found_libc +_LIBC: str = _found_libc or "" +# A skip, not a module-level raise: raising here was a *collection* error, so +# on a machine with no findable C library (Windows) pytest ran none of the +# suite's other tests either. Only the tests that load a real library need +# one; the loader-defers tests below run everywhere. +_needs_libc = pytest.mark.skipif( + _found_libc is None, reason="needs a real C library as a stand-in (POSIX only)" +) def test_import_does_not_touch_the_filesystem() -> None: @@ -43,11 +48,13 @@ def test_missing_library_is_not_available() -> None: assert lib.is_available() is False +@_needs_libc def test_real_library_is_available() -> None: lib = LazyLibrary(_LIBC) assert lib.is_available() is True +@_needs_libc def test_real_function_call_round_trips() -> None: lib = LazyLibrary(_LIBC) abs_ = lib.function("abs", (c_int,), c_int) @@ -67,6 +74,7 @@ def test_function_result_is_cached_across_calls() -> None: abs_(-1) +@_needs_libc def test_missing_symbol_raises_library_not_found_error() -> None: lib = LazyLibrary(_LIBC) nonexistent = lib.function("this_symbol_does_not_exist_in_libc", (c_char_p,), c_int) @@ -74,6 +82,7 @@ def test_missing_symbol_raises_library_not_found_error() -> None: nonexistent(b"x") +@_needs_libc def test_two_lazy_libraries_are_independent() -> None: good = LazyLibrary(_LIBC) bad = LazyLibrary("this-library-definitely-does-not-exist.so.999")