fn repo_file(name: &str) -> Option<String> {
let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
.join("../..")
.join(name);
std::fs::read_to_string(path).ok()
}
fn series() -> String {
let v = env!("CARGO_PKG_VERSION");
let mut parts = v.split('.');
let major = parts.next().expect("a version has a major");
let minor = parts.next().expect("a version has a minor");
format!("{major}.{minor}")
}
#[test]
fn the_install_lines_quote_the_current_series() {
let want = series();
let needle = "dualis = \"";
let mut checked = 0;
for file in ["AGENTS.md", "README.md", "CONTRIBUTING.md", "CLAUDE.md"] {
let Some(text) = repo_file(file) else {
continue;
};
for (line_no, line) in text.lines().enumerate() {
let Some(at) = line.find(needle) else {
continue;
};
let rest = &line[at + needle.len()..];
let quoted = rest.split('"').next().unwrap_or("");
if quoted.chars().filter(|c| *c == '.').count() != 1 {
continue;
}
checked += 1;
assert_eq!(
quoted,
want,
"{file}:{} says dualis = {quoted:?} but this crate is {}. Bump the prose \
with the release.",
line_no + 1,
env!("CARGO_PKG_VERSION")
);
}
}
if repo_file("AGENTS.md").is_some() {
assert!(
checked > 0,
"no `dualis = \"x.y\"` line found in the documentation — either it was reworded, \
in which case update this test, or it was deleted, in which case a caller no \
longer has one to copy"
);
}
}