crates/jera/tests/runners_feature.rs
//! **The ledger without the runners** (lane B4, A31 §7.5).
//!
//! jera is two things: the durable job ledger (`jobs`, `policy`, `agent`), and
//! the runners that boot a job's instance (`boot`, `container`, `vm`), which go
//! through draupnir (19k lines: KVM, OCI, Redfish). Holger uses the ledger alone
//! and linked draupnir in every build for one enum. The runners now sit behind
//! `runners`, in the default, so every consumer that uses them keeps them and a
//! `default-features = false` ledger links no draupnir.
fn section<'a>(text: &'a str, name: &str) -> Vec<&'a str> {
let mut out = Vec::new();
let mut inside = false;
for l in text.lines() {
let t = l.trim();
if t.starts_with('[') {
inside = t == name;
continue;
}
if inside && !t.starts_with('#') && !t.is_empty() {
out.push(t);
}
}
out
}
#[test]
fn draupnir_is_the_runners_feature_and_the_runners_are_default() {
let me = include_str!("../Cargo.toml");
let deps = section(me, "[dependencies]");
let d = deps.iter().find(|l| l.starts_with("draupnir =")).expect("draupnir");
assert!(d.contains("optional = true"), "{d}");
let features = section(me, "[features]");
let f = |k: &str| features.iter().copied().find(|l| l.starts_with(&format!("{k} ="))).unwrap_or_else(|| panic!("no `{k}`"));
assert!(f("runners").contains("dep:draupnir"));
assert!(f("default").contains("\"runners\""), "every default consumer keeps the runners");
for backend in ["vm-tunnr", "container-oci"] {
assert!(f(backend).contains("\"runners\""), "{backend} is a runner backend");
}
}
/// The ledger and its policy are there without the runners.
#[test]
fn the_ledger_and_its_policy_need_no_runner() {
use jera::policy::JobPolicy;
let p = JobPolicy::Container;
assert_eq!(JobPolicy::from_boot_mode(p.boot_mode()), p);
assert!(p.delegates_to_draupnir(), "the policy still names where it goes");
#[cfg(feature = "runners")]
assert!(p.draupnir_kind().is_some());
}