whiskers.git / crates / whiskers-core / tests / private_terms.rs

The repository must not name a family or a machine. tools/check-private.sh greps the tracked files for the terms in the gitignored .private-terms; running it here makes cargo test fail the moment one slips in. Without that file there is nothing to check against and this passes.

5use std::path::Path;
6use std::process::Command;
8#[test]
9fn no_tracked_file_contains_a_private_term() {
10    let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../..");
11    let out = Command::new("bash").arg("tools/check-private.sh").current_dir(&root).output().expect("bash is available");
12    assert!(out.status.success(), "{}", String::from_utf8_lossy(&out.stderr));
13}
14
15#[test]
16fn the_check_finds_a_planted_term_and_reports_where_without_echoing_it() {
17    let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../..");
18    let dir = std::env::temp_dir().join(format!("whiskers-private-{}", std::process::id()));
19    std::fs::create_dir_all(&dir).unwrap();
20    let terms = dir.join("terms");
21    // README.md names the product, so "Whiskers" is a term guaranteed to be present.
22    std::fs::write(&terms, "# a comment\n\nwhiskers\n").unwrap();
23    let out = Command::new("bash").arg("tools/check-private.sh").arg(&terms).current_dir(&root).output().unwrap();
24    assert_eq!(out.status.code(), Some(1));
25    let err = String::from_utf8_lossy(&out.stderr);
26    assert!(err.contains("README.md:"), "{err}");
27    assert!(!err.to_lowercase().contains("whiskers is"), "the matching text must not be echoed: {err}");
28}