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"
);
}
}
#[test]
fn the_agents_know_what_version_the_tree_is() {
let full = env!("CARGO_PKG_VERSION");
let needle = "the tree is ";
let mut checked = 0;
let dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../../.claude/agents");
let Ok(entries) = std::fs::read_dir(&dir) else {
return; };
let mut files: Vec<_> = entries.filter_map(|e| e.ok().map(|e| e.path())).collect();
files.sort();
for path in files {
let Ok(text) = std::fs::read_to_string(&path) else {
continue;
};
for (line_no, line) in text.lines().enumerate() {
let Some(at) = line.find(needle) else {
continue;
};
let stated: String = line[at + needle.len()..]
.chars()
.take_while(|c| c.is_ascii_digit() || *c == '.')
.collect();
let stated = stated.trim_end_matches('.');
if stated.is_empty() {
continue;
}
checked += 1;
assert_eq!(
stated,
full,
"{}:{} says the tree is {stated:?}, and it is {full:?}",
path.file_name().unwrap_or_default().to_string_lossy(),
line_no + 1
);
}
}
assert!(
checked > 0,
"no agent states what version the tree is — if that sentence was reworded, update this \
test rather than letting it pass on finding nothing"
);
}