Skip to content

Commit 4dcad1e

Browse files
authored
Merge pull request #14 from ctrondlp/P2-portable-suite-and-api-count
fix: skip the four loader tests that need a real C library and the th…
2 parents 60ff933 + 50f818f commit 4dcad1e

7 files changed

Lines changed: 49 additions & 7 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,24 @@ All notable changes to python-libei are recorded here. The format follows
55
[semantic versioning](https://semver.org/spec/v2.0.0.html) — with the usual
66
0.x caveat that the API may still change between minor versions.
77

8+
## [Unreleased]
9+
10+
### Fixed
11+
12+
- **The test suite ran nothing at all off Linux and FreeBSD.** `tests/test_loader.py`
13+
raised at module level when `ctypes.util.find_library("c")` found no C library,
14+
which pytest reports as a *collection* error -- so on Windows `pytest -q -rs`
15+
stopped before any of the other 200-odd tests, including every pure-Python one.
16+
The four loader tests that need a real library now skip there instead, and the
17+
three tests that build a keymap with `os.memfd_create` skip where it does not
18+
exist. On Windows the suite now reports 212 passed, 18 skipped; on Linux nothing
19+
changes -- 230 passed against libei 1.6.0.
20+
- **The count of unbound gesture/stylus functions was stale.** The README and
21+
`docs/developers/architecture.md` said libei's `main` adds 22; counted against
22+
1.6.0's headers on 2026-09-30 it is 46 in libei and 51 in libeis, now that the
23+
stylus protocol has landed there too. Still none of it is in a release, so still
24+
none of it is bound.
25+
826
## [0.6.0] - 2026-09-22
927

1028
### Added

‎README.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,9 @@ because a skimming reader could otherwise take them as supported. 1.6.0's own
106106
`enum ei_device_capability` stops at `TEXT`, and its `enum ei_event_type`
107107
stops at `EI_EVENT_TEXT_UTF8` — so the swipe/pinch/hold/stylus members of
108108
`EventType` cannot arrive either. The values here match upstream `main`
109-
exactly, so they are ready for whatever release adds them. The 22
110-
gesture/stylus accessor functions `main` adds are deliberately not bound:
109+
exactly, so they are ready for whatever release adds them. The gesture
110+
and stylus functions `main` adds -- 46 in libei and 51 in libeis against
111+
1.6.0's headers, counted 2026-09-30 -- are deliberately not bound:
111112
nothing that ships today exports them, so nothing here could be verified
112113
against a real library, which is the bar every other binding in this package
113114
was held to.

‎docs/developers/architecture.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,10 @@ deliberate:
5555
is only ever created by its own `create_for_*()`, never wrapped from a raw
5656
pointer.
5757

58-
The 22 gesture/stylus accessor functions that libei's `main` branch adds are
59-
also unbound. Nothing that ships today exports them, so nothing here could be
58+
The gesture and stylus functions that libei's `main` branch adds -- 46 in
59+
libei and 51 in libeis against 1.6.0's headers, counted 2026-09-30: the
60+
swipe, pinch and hold senders and event getters, and the whole stylus
61+
protocol -- are also unbound. Nothing that ships today exports them, so nothing here could be
6062
verified against a real library — which is the bar every other binding in this
6163
package was held to.
6264

‎tests/test_ei_objects.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,10 @@ def test_peek_event_type_is_none_on_an_empty_queue(
735735
assert ctx.peek_event_type() is None
736736

737737

738+
@pytest.mark.skipif(
739+
not hasattr(os, "memfd_create"),
740+
reason="os.memfd_create is Linux/FreeBSD only",
741+
)
738742
def test_keymap_fd_is_rewound(monkeypatch: pytest.MonkeyPatch) -> None:
739743
# dup(2) shares the file offset, and libei leaves its own fd at EOF --
740744
# without a rewind the caller reads zero bytes and no error, which looks

‎tests/test_eis_objects.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,10 @@ def test_region_mapping_id_round_trips(monkeypatch: pytest.MonkeyPatch) -> None:
385385
assert region.mapping_id == "screen-0"
386386

387387

388+
@pytest.mark.skipif(
389+
not hasattr(os, "memfd_create"),
390+
reason="os.memfd_create is Linux/FreeBSD only",
391+
)
388392
def test_keymap_fd_is_rewound(monkeypatch: pytest.MonkeyPatch) -> None:
389393
fd = os.memfd_create("keymap")
390394
try:

‎tests/test_integration_extras.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,10 @@ def on_client_event(event: ei.Event) -> None:
229229
assert pongs[0] == sent_id[0]
230230

231231

232+
@pytest.mark.skipif(
233+
not hasattr(os, "memfd_create"),
234+
reason="os.memfd_create is Linux/FreeBSD only",
235+
)
232236
def test_keymap_transfers_and_reads_back() -> None:
233237
keymap_text = b"xkb_keymap { /* test */ };\x00"
234238
source = os.memfd_create("test-keymap")

‎tests/test_loader.py‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,14 @@
1818
from libei._capi.loader import LazyLibrary, LibraryNotFoundError
1919

2020
_found_libc = util.find_library("c")
21-
if _found_libc is None:
22-
raise RuntimeError("no C library found -- these tests need one to stand in")
23-
_LIBC: str = _found_libc
21+
_LIBC: str = _found_libc or ""
22+
# A skip, not a module-level raise: raising here was a *collection* error, so
23+
# on a machine with no findable C library (Windows) pytest ran none of the
24+
# suite's other tests either. Only the tests that load a real library need
25+
# one; the loader-defers tests below run everywhere.
26+
_needs_libc = pytest.mark.skipif(
27+
_found_libc is None, reason="needs a real C library as a stand-in (POSIX only)"
28+
)
2429

2530

2631
def test_import_does_not_touch_the_filesystem() -> None:
@@ -43,11 +48,13 @@ def test_missing_library_is_not_available() -> None:
4348
assert lib.is_available() is False
4449

4550

51+
@_needs_libc
4652
def test_real_library_is_available() -> None:
4753
lib = LazyLibrary(_LIBC)
4854
assert lib.is_available() is True
4955

5056

57+
@_needs_libc
5158
def test_real_function_call_round_trips() -> None:
5259
lib = LazyLibrary(_LIBC)
5360
abs_ = lib.function("abs", (c_int,), c_int)
@@ -67,13 +74,15 @@ def test_function_result_is_cached_across_calls() -> None:
6774
abs_(-1)
6875

6976

77+
@_needs_libc
7078
def test_missing_symbol_raises_library_not_found_error() -> None:
7179
lib = LazyLibrary(_LIBC)
7280
nonexistent = lib.function("this_symbol_does_not_exist_in_libc", (c_char_p,), c_int)
7381
with pytest.raises(LibraryNotFoundError, match="does not export"):
7482
nonexistent(b"x")
7583

7684

85+
@_needs_libc
7786
def test_two_lazy_libraries_are_independent() -> None:
7887
good = LazyLibrary(_LIBC)
7988
bad = LazyLibrary("this-library-definitely-does-not-exist.so.999")

0 commit comments

Comments
 (0)