Skip to content

Plan, apply and roll back changes to a production ontology, with a blast radius report and a proof an auditor can re-check.

Stop the differential corpus reading a generated directory (#177)

Fabio Rovai4284a1cadc97
diff --git a/tests/cross_kernel_differential_test.rs b/tests/cross_kernel_differential_test.rs
index a5645014..c2763607 100644
--- a/tests/cross_kernel_differential_test.rs
+++ b/tests/cross_kernel_differential_test.rs
@@ -793,7 +793,11 @@ fn source_graphs() -> Vec<PathBuf> {
"benchmark/epc",
"benchmark/gvr",
"benchmark/mushroom",
- "demo/derived",
+ // NOT demo/derived: it is generated by the demo and gitignored, so a
+ // machine that has run the demo scanned 19 extra .ttl and measured a
+ // different corpus from CI (2,405 triples against 2,075). The figures
+ // below are derived from this list, so the corpus has to be the same
+ // everywhere or the derivation is of nothing. #173.
"demo/corpus/dcat-us",
"tests/w3c-shacl/core/complex",
"tests/data",
@@ -814,6 +818,67 @@ fn source_graphs() -> Vec<PathBuf> {
out
}
+/// **#173.** Every file in the corpus must be one git tracks.
+///
+/// The figures the tests below assert are derived from this corpus, so the
+/// corpus has to be identical on every machine or the derivation describes
+/// nothing. It was not: `demo/derived/` is generated by the demo and
+/// gitignored, so a developer who had run the demo measured 2,405 triples
+/// where CI measured 2,075, and the disagreement looked like a platform
+/// difference rather than a directory listing.
+///
+/// Removing that one entry fixes today's corpus and nothing stops the next
+/// one. This asks git directly, so any generated or untracked path added
+/// later fails here instead of quietly changing what the numbers mean.
+#[test]
+fn the_corpus_contains_only_files_git_tracks() {
+ let files = source_graphs();
+ assert!(!files.is_empty(), "the corpus is empty, so this test would pass vacuously");
+
+ let mut input = String::new();
+ for f in &files {
+ input.push_str(f.to_str().expect("corpus path is valid UTF-8"));
+ input.push('\n');
+ }
+
+ let mut child = std::process::Command::new("git")
+ .args(["check-ignore", "--stdin"])
+ .current_dir(repo())
+ .stdin(std::process::Stdio::piped())
+ .stdout(std::process::Stdio::piped())
+ .stderr(std::process::Stdio::piped())
+ .spawn()
+ .expect("run git check-ignore; git is required to know what is generated");
+ {
+ use std::io::Write;
+ child.stdin.as_mut().expect("stdin").write_all(input.as_bytes()).expect("write paths");
+ }
+ let out = child.wait_with_output().expect("collect git check-ignore");
+
+ // Exit 0 means at least one path is ignored, 1 means none are. Anything
+ // else is git failing, which must not read as "nothing is ignored".
+ let code = out.status.code().unwrap_or(-1);
+ assert!(
+ code == 0 || code == 1,
+ "git check-ignore failed with {code}, so this gate proved nothing:\n{}",
+ String::from_utf8_lossy(&out.stderr)
+ );
+
+ let ignored: Vec<&str> = std::str::from_utf8(&out.stdout)
+ .expect("git output is UTF-8")
+ .lines()
+ .filter(|l| !l.trim().is_empty())
+ .collect();
+ assert!(
+ ignored.is_empty(),
+ "{} corpus file(s) are gitignored, so this machine measures a corpus CI \
+ never sees. Drop the directory from `source_graphs`, or commit the \
+ files if they belong in the corpus:\n {}",
+ ignored.len(),
+ ignored.join("\n ")
+ );
+}
+
/// Generate one certificate per (graph, rule table) pair, using the engine as the
/// producer. Steps are capped: a prefix of a valid certificate is a valid certificate,
/// because a step may only cite what came strictly before it, so truncation cannot turn