summaryrefslogtreecommitdiffstats
path: root/tests/architecture.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/architecture.rs')
-rw-r--r--tests/architecture.rs62
1 files changed, 62 insertions, 0 deletions
diff --git a/tests/architecture.rs b/tests/architecture.rs
index 882adee..12de924 100644
--- a/tests/architecture.rs
+++ b/tests/architecture.rs
@@ -682,6 +682,34 @@ fn the_test_surface_is_disposed_of() {
unconfirmed.join("\n")
);
+ // A row is `ambiguous` when the only evidence that production uses the item
+ // is a bare mention of a name the detector cannot resolve — `new`, `open`
+ // and `record` are declared in many modules, and a line saying `Foo::new()`
+ // in http says nothing about `db::open`. The tool genuinely does not know,
+ // so a human has to say which item the mention meant and record the verdict.
+ let mut unadjudicated = Vec::new();
+ for row in rows {
+ if row.get("ambiguous").and_then(|v| v.as_bool()).unwrap_or(false)
+ && !row.get("adjudicated").and_then(|v| v.as_bool()).unwrap_or(false)
+ {
+ unadjudicated.push(format!(
+ "{}:{} at {}",
+ row.get("module").and_then(|v| v.as_str()).unwrap_or("?"),
+ row.get("name").and_then(|v| v.as_str()).unwrap_or("?"),
+ row.get("where").and_then(|v| v.as_str()).unwrap_or("?")
+ ));
+ }
+ }
+ assert!(
+ unadjudicated.is_empty(),
+ "{} items look production-used only because a bare mention of a colliding \n\
+ name could have meant them, and no human has said which item the mention \n\
+ referred to. Read the cited line and record the verdict in \n\
+ tools/test-surface-ambiguous.json:\n{}",
+ unadjudicated.len(),
+ unadjudicated.join("\n")
+ );
+
let budget = budget_section("test_surface");
let surface = &budget;
let counts = report.get("counts").and_then(|c| c.as_object()).expect("counts");
@@ -708,3 +736,37 @@ fn the_test_surface_is_disposed_of() {
tighter.join("\n")
);
}
+
+/// The definitive check, and the slow one: compile a throwaway crate against
+/// `aur-build` twice, once without `test-support` and once with it, and try to
+/// name every dispositioned item from outside.
+///
+/// `tools/test-surface.py` infers the test surface by reading source, and
+/// inference has been wrong before — a name matched inside a string literal
+/// made `review::approve::withdraw` look production-used, and keying rows by
+/// bare name merged `pipeline::dispatch::Pool::shutdown` into the gated
+/// `db::Writer::shutdown` row. This test does not read source. It asks the
+/// compiler what a release build actually lets an outside crate reach.
+///
+/// `#[ignore]`d because it builds the library twice from scratch, roughly
+/// doubling the suite. Run it with `cargo test --test architecture -- --ignored`
+/// or `AUR_PROBE_RELEASE_SURFACE=1 cargo test --test architecture`.
+#[test]
+#[ignore = "builds the library twice; run with --ignored or AUR_PROBE_RELEASE_SURFACE=1"]
+fn the_release_build_exports_nothing_that_only_tests_reach() {
+ let out = std::process::Command::new("python3")
+ .arg("tools/release-surface-probe.py")
+ .current_dir(root())
+ .output()
+ .expect("run tools/release-surface-probe.py");
+ let text = String::from_utf8_lossy(&out.stdout).to_string();
+ assert!(
+ out.status.success(),
+ "a release build still exports something only the test tier needs:\n{text}{}",
+ String::from_utf8_lossy(&out.stderr)
+ );
+ assert!(
+ text.contains("nothing leaked"),
+ "the probe did not report success:\n{text}"
+ );
+}