matrix_skip_plugin
matrix_skip_plugin
¶
Runtime-aware skip plugin for matrix test runs.
A matrix slot runs its whole suite in one runtime — a shared-kernel container (crun/runc) or a libkrun microVM (krun). Some tests cannot run in a given runtime by construction: a krun microVM has its own kernel but cannot launch nested containers and has no host loopback stack, while a shared-kernel container cannot give a test the isolated kernel it needs. Such a test must skip in the runtime it cannot use — not fail — so a slot reports green for what it actually can run.
This plugin auto-skips those tests, tagged by the marker that governs
them, and writes separate matrix and ordinary pytest skip counts to
<results>/<slot>.skips.json when the run is inside the matrix (the
runner reads them into the closing SKIPPED summary). The rules apply
off-matrix too — a developer box without krun skips needs_krun tests —
but no file is written there.
Skip rules (marker → skip when):
needs_krun— skip unless the runtime is krun (own kernel).needs_loopback— skip under krun (its TSI intercepts loopback server sockets, so bind-then-connect tests cannot pass).needs_vm— skip inside any matrix container (needs a full VM/HW: real LSM enforcement, a non-nested podman); reserved for the VM backend.needs_x86— skip when the host is notx86_64.
The podman / nested-container suite (needs_podman) is deliberately NOT
skipped on krun: exercising it under an own kernel is the reason a krun
slot exists. A nested-podman failure there is a setup bug to fix (e.g. the
storage driver), not a skip.
The plugin is loaded through a pytest11 entry point, so every repo
that depends on terok-util gets it without wiring a conftest. It lives as
a top-level module (not under the matrix package) and imports its
catalog constants lazily inside the hooks: pytest loads a pytest11
plugin at bootstrap, before coverage instrumentation starts, so pulling the
matrix package in at import time would hide that whole package's real
coverage behind a bootstrap-load artifact.
pytest_configure(config)
¶
Register the runtime markers this plugin owns for --strict-markers.
Source code in src/terok_util/matrix_skip_plugin.py
pytest_collection_modifyitems(items)
¶
Mark tests the current runtime cannot run without counting deselections.
Source code in src/terok_util/matrix_skip_plugin.py
pytest_runtest_makereport(item)
¶
Count the final test outcome after pytest has distinguished skips from xfail.
Source code in src/terok_util/matrix_skip_plugin.py
pytest_make_collect_report(collector)
¶
Include collection skips such as a module-level pytest.importorskip.
Source code in src/terok_util/matrix_skip_plugin.py
pytest_sessionfinish(session)
¶
In-matrix, merge this invocation's skip counts into the slot's file.
A slot runs several pytest phases (unit, integration) as separate invocations; each merges its counts so the runner sees the slot total.