Skip to main content

Crate lihaaf

Crate lihaaf 

Source
Expand description

Fast compile-fail and compile-pass testing for Rust proc macros.

lihaaf is a trybuild-style test harness optimized for quick iteration. It is designed for proc-macro crates that need many compile-pass and compile-fail fixtures without paying unnecessary rebuild overhead.

lihaaf (“quilt”; Urdu and Punjabi, also written ਲਿਹਾਫ਼ in Gurmukhi) compiles the consumer crate once as a dynamic library, then runs each fixture as a standalone rustc invocation that links the prebuilt dylib via --extern. In many real projects this is the difference between waiting forever and getting quick feedback.

§Public surface

The exposed surface is intentionally CLI-shaped:

  • The cargo-lihaaf binary (Cargo subcommand convention; invoked as cargo lihaaf [OPTIONS]).
  • [package.metadata.lihaaf] schema in the consumer’s Cargo.toml (see config::Config).
  • Verdict catalog (see verdict::Verdict) and exit codes (see exit::ExitCode).
  • A small set of crate-root re-exports for adopters who do want to drive lihaaf from Rust: Cli, Config, Verdict, ExitCode, Error, Outcome, run, Report.
  • Compat mode (cargo lihaaf --compat): a migration workflow for trybuild fixture corpora that generates a deterministic JSON comparison envelope. The compat mode Rust API surface is intentionally #[doc(hidden)]; the supported entry is always the CLI.

All other modules are pub(crate) and may evolve freely across v0.1.x point releases. Adopters who want to drive lihaaf from Rust today should prefer the crate-root re-exports above (or subprocess-spawn cargo lihaaf); the internal module paths are not part of any v0.1 stability contract.

§What lives where

ModuleResponsibility
cliclap argument parsing, flag-to-action mapping.
configParse + validate [package.metadata.lihaaf].
toolchainCapture rustc --version --verbose for drift checks. (pub(crate))
dylibcargo rustc --crate-type=dylib invocation, copy mechanic. (pub(crate))
suite_workspaceOpted-in staged Cargo workspace that builds fixture dev_deps beside the dylib. (pub(crate))
manifesttarget/lihaaf/manifest.json schema + atomic write. (pub(crate))
freshnessPer-dispatch the policy invariant re-check (mtime / SHA-256 / rustc). (pub(crate))
lockSession-wide advisory file lock on target/lihaaf/.session.lock. (pub(crate))
discoveryWalk fixture_dirs, classify pass/fail, sort. (pub(crate))
workerPer-fixture rustc spawn, RSS sampling, OOM, timeout. (pub(crate))
normalizeStderr normalization (fixed-string, byte-level). (pub(crate))
diffHand-rolled Myers diff with line granularity. (pub(crate))
snapshot.stderr file I/O + --bless semantics. (pub(crate))
verdictPer-fixture verdict + session reporter.
exitExit-code mapping per the policy.
sessionLifecycle orchestration (stages 1–9 of the policy). (pub(crate))
errorCrate-wide error type. (pub(crate))
utilAtomic file write + sha256 helpers. (pub(crate))

Re-exports§

pub use cli::Cli;
pub use config::Config;
pub use exit::ExitCode;
pub use verdict::Verdict;

Modules§

cli
CLI argument parsing.
config
[package.metadata.lihaaf] parsing + validation.
exit
Exit codes for the v0.1 stable contract.
verdict
Per-fixture verdict catalog.

Structs§

Report
Aggregate result of a session run.

Enums§

Error
Crate-wide error type.
Outcome
Session outcomes reported before fixture verdicts can run.

Constants§

VERSION
The semver-stable lihaaf release the binary identifies as.

Functions§

run
Run the full session.