tests/lock_committed.rs
//! **The lockfile is committed, and it is current.** A Build Thing cell builds
//! with `cargo … --locked` inside the pinned toolchain image; with `Cargo.lock`
//! gitignored there was no lock to be locked to, so every skade container cell
//! failed on every box (sweep 2026-10-16). Same decision as nornir's lock: the
//! lock is source.
use std::path::Path;
use std::process::Command;
fn root() -> &'static Path {
Path::new(env!("CARGO_MANIFEST_DIR"))
}
#[test]
fn cargo_lock_is_tracked_and_not_ignored() {
assert!(root().join("Cargo.lock").is_file(), "no Cargo.lock at the repo root");
let ignore = std::fs::read_to_string(root().join(".gitignore")).unwrap_or_default();
assert!(
!ignore.lines().any(|l| matches!(l.trim(), "Cargo.lock" | "/Cargo.lock")),
".gitignore still ignores Cargo.lock"
);
if root().join(".git").exists() {
let out = Command::new("git").args(["ls-files", "--error-unmatch", "Cargo.lock"]).current_dir(root()).output().unwrap();
assert!(out.status.success(), "Cargo.lock is not tracked by git");
}
}
#[test]
fn cargo_lock_is_current_for_a_locked_build() {
let out = Command::new(env!("CARGO"))
.args(["metadata", "--locked", "--offline", "--format-version", "1", "--no-deps"])
.current_dir(root())
.output()
.unwrap();
assert!(out.status.success(), "`cargo metadata --locked` refuses the lock: {}", String::from_utf8_lossy(&out.stderr));
}