#[cfg(test)]
mod tests {
use std::path::{Path, PathBuf};
fn repo_root() -> PathBuf {
Path::new(env!("CARGO_MANIFEST_DIR"))
.parent()
.and_then(Path::parent)
.expect("crates/varve-core is two levels below the repo root")
.to_path_buf()
}
fn quoted(line: &str) -> Option<&str> {
let (_, rest) = line.split_once("version")?;
let (_, rest) = rest.split_once('"')?;
let (v, _) = rest.split_once('"')?;
Some(v)
}
#[test]
fn the_workspace_version_and_the_internal_dependency_pin_agree() {
let manifest = std::fs::read_to_string(repo_root().join("Cargo.toml"))
.expect("the workspace manifest is readable");
let workspace = manifest
.lines()
.find(|l| l.trim_start().starts_with("version"))
.and_then(quoted)
.expect("the workspace declares a version");
let dep_line = manifest
.lines()
.find(|l| l.contains("varve-core") && l.contains("path"))
.expect("varve depends on varve-core by path");
let pinned = quoted(dep_line).expect("the path dependency also pins a version");
assert_eq!(
pinned, workspace,
"varve pins varve-core {pinned} but the workspace is {workspace}. \
`cargo package` embeds this requirement, so the published crate \
would ask for a varve-core it was never built against — and \
`cargo publish` refuses, AFTER the tag exists. Bump both."
);
}
}