Skip to main content

Module test_capability

Module test_capability 

Source
Expand description

Runtime-gated test support: skip loudly, and fail where the capability is required, so a silent skip cannot masquerade as a pass. Runtime-gated tests: skip loudly, and fail where the capability is required.

A test that returns early because a tool is missing prints ok. libtest reports it identically to a test that did the work, and the eprintln! explaining the skip is captured and never shown unless the test fails. So a capability can quietly stop being exercised while CI keeps reporting success — indefinitely, and invisibly.

That is not hypothetical. command_available did not consult PATHEXT, so sandbox_container::detect() never found docker.exe and the Windows container tests skipped for the life of that CI lane. When the lookup was fixed they ran for the first time and immediately failed on two real bugs. The lane had been green throughout.

AGENTS.md rule 5 already guards the neighbouring shape — a test FILTER matching zero tests — with grep -qE 'test result: ok\. [1-9]'. This module guards the other one.

§Contract

Call skip instead of a bare eprintln! + return. It emits a stable, greppable marker, and PANICS when the capability appears in KRANZ_REQUIRED_CAPABILITIES — so a platform that is supposed to have a tool fails loudly the moment it stops having one, instead of silently reverting to skips.

CI declares per-platform expectations rather than asserting a skip list after the fact: ubuntu requires git,bwrap,container,grep, macOS requires git,sandbox-exec, and Windows requires git. macOS and Windows omit container — the provider is supported only on Linux and session and gate resolution fail closed elsewhere.

Modules§

capability
Capability names. Constants rather than loose strings so a typo in a test cannot silently opt out of the requirement it meant to declare.

Constants§

REQUIRED_CAPABILITIES_ENV
Environment variable naming the capabilities that MUST be present. Comma-separated; matching is exact and case-insensitive.
SKIP_LOG_ENV
Optional file the skip ledger is appended to.
SKIP_MARKER
Prefix on every skip line, so a run can be searched for what it did not do.

Functions§

is_required
True when capability is listed in REQUIRED_CAPABILITIES_ENV.
skip
Record that a runtime-gated test is skipping for want of capability.