summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/architecture-budget.json102
-rw-r--r--tests/architecture.rs216
-rw-r--r--tests/common/mod.rs34
-rw-r--r--tests/config.rs8
-rw-r--r--tests/kata.rs5
-rw-r--r--tests/state_machine.rs5
-rw-r--r--tests/versions.rs8
7 files changed, 129 insertions, 249 deletions
diff --git a/tests/architecture-budget.json b/tests/architecture-budget.json
index 13dbe01..49098b3 100644
--- a/tests/architecture-budget.json
+++ b/tests/architecture-budget.json
@@ -5,6 +5,7 @@
"db.PackageRow": "what `index_packages` answers with, and `index_packages` is `pub`; narrowing the row is `private_interfaces` - type `PackageRow` is more private than the item `index_packages`. http, the publish step and the `aur-build` binary bind it without naming it",
"db.Subscription": "what `get_subscription` and `list_subscriptions` answer with, both `pub`; narrowing it is `private_interfaces` on `list_subscriptions`. `watch`, `usecase`, the binary and tests/detect.rs bind the value without naming the type",
"db.Unbuilt": "the attention row `approved_but_unbuilt` returns, and that fn is `pub`; narrowing it is `private_interfaces` on `approved_but_unbuilt`. The web UI and tests/crash.rs bind it without naming it",
+ "db.Writer": "what `Db::writer` is typed as, and the parameter of the `pub` write functions in `db`; narrowing it makes those signatures name a private type - the compiler says `type db::Writer is private` at every call site, tests included",
"pkginfo.Installed": "what `parse_installed` answers with, and `parse_installed` is `pub`; narrowing it is `private_interfaces` on `parse_installed`. `pipeline`, `shims` and tests/world.rs read it line by line",
"pkginfo.PkgInfo": "what `parse_pkginfo` answers with, and `parse_pkginfo` is `pub`; narrowing it is `private_interfaces` on `parse_pkginfo`. `pipeline`, `shims` and tests/world.rs read its fields, never its name",
"review.BulkItem": "one outcome of `approve::bulk`, which is `pub` and which tests/approve.rs drives directly; narrowing the row is `private_interfaces` on `approve::bulk`",
@@ -128,9 +129,9 @@
"dead": 0,
"deadonly": 0,
"glob": 0,
- "largest": 50,
+ "largest": 47,
"largest_file": "src/bin/sandbox-agent.rs",
- "lines": 50,
+ "lines": 47,
"overwide": 0,
"priv": 0,
"pub": 0,
@@ -140,33 +141,33 @@
"dead": 2,
"deadonly": 0,
"glob": 0,
- "largest": 699,
+ "largest": 650,
"largest_file": "src/config.rs",
- "lines": 699,
+ "lines": 650,
"overwide": 0,
"priv": 0,
"pub": 29,
"test": 2
},
"db": {
- "dead": 11,
+ "dead": 10,
"deadonly": 0,
"glob": 0,
- "largest": 368,
+ "largest": 358,
"largest_file": "src/db/mod.rs",
- "lines": 3890,
+ "lines": 3574,
"overwide": 0,
"priv": 15,
"pub": 189,
- "test": 11
+ "test": 10
},
"error": {
"dead": 0,
"deadonly": 0,
"glob": 0,
- "largest": 428,
+ "largest": 399,
"largest_file": "src/error.rs",
- "lines": 428,
+ "lines": 399,
"overwide": 0,
"priv": 0,
"pub": 21,
@@ -176,9 +177,9 @@
"dead": 0,
"deadonly": 0,
"glob": 0,
- "largest": 57,
+ "largest": 55,
"largest_file": "src/fetch.rs",
- "lines": 57,
+ "lines": 55,
"overwide": 0,
"priv": 0,
"pub": 1,
@@ -188,9 +189,9 @@
"dead": 0,
"deadonly": 0,
"glob": 0,
- "largest": 240,
+ "largest": 219,
"largest_file": "src/git.rs",
- "lines": 240,
+ "lines": 219,
"overwide": 0,
"priv": 0,
"pub": 14,
@@ -200,9 +201,9 @@
"dead": 0,
"deadonly": 0,
"glob": 0,
- "largest": 112,
+ "largest": 108,
"largest_file": "src/hash.rs",
- "lines": 112,
+ "lines": 108,
"overwide": 0,
"priv": 0,
"pub": 7,
@@ -212,9 +213,9 @@
"dead": 5,
"deadonly": 0,
"glob": 0,
- "largest": 565,
+ "largest": 524,
"largest_file": "src/http/routes/pages.rs",
- "lines": 2035,
+ "lines": 1916,
"overwide": 0,
"priv": 71,
"pub": 17,
@@ -236,9 +237,9 @@
"dead": 0,
"deadonly": 0,
"glob": 0,
- "largest": 314,
+ "largest": 321,
"largest_file": "src/main.rs",
- "lines": 314,
+ "lines": 321,
"overwide": 0,
"priv": 0,
"pub": 0,
@@ -248,9 +249,9 @@
"dead": 3,
"deadonly": 0,
"glob": 0,
- "largest": 455,
+ "largest": 442,
"largest_file": "src/ops.rs",
- "lines": 455,
+ "lines": 442,
"overwide": 0,
"priv": 2,
"pub": 11,
@@ -260,9 +261,9 @@
"dead": 6,
"deadonly": 0,
"glob": 0,
- "largest": 472,
+ "largest": 445,
"largest_file": "src/pipeline/steps.rs",
- "lines": 1410,
+ "lines": 1319,
"overwide": 0,
"priv": 4,
"pub": 21,
@@ -272,9 +273,9 @@
"dead": 0,
"deadonly": 0,
"glob": 0,
- "largest": 117,
+ "largest": 115,
"largest_file": "src/pkginfo.rs",
- "lines": 117,
+ "lines": 115,
"overwide": 0,
"priv": 0,
"pub": 6,
@@ -284,9 +285,9 @@
"dead": 0,
"deadonly": 0,
"glob": 0,
- "largest": 559,
+ "largest": 543,
"largest_file": "src/pkgver/mod.rs",
- "lines": 559,
+ "lines": 543,
"overwide": 0,
"priv": 0,
"pub": 7,
@@ -296,9 +297,9 @@
"dead": 0,
"deadonly": 0,
"glob": 0,
- "largest": 459,
+ "largest": 436,
"largest_file": "src/recipe.rs",
- "lines": 459,
+ "lines": 436,
"overwide": 0,
"priv": 0,
"pub": 7,
@@ -308,9 +309,9 @@
"dead": 4,
"deadonly": 0,
"glob": 0,
- "largest": 301,
+ "largest": 317,
"largest_file": "src/review/diff.rs",
- "lines": 915,
+ "lines": 924,
"overwide": 0,
"priv": 4,
"pub": 24,
@@ -320,9 +321,9 @@
"dead": 7,
"deadonly": 0,
"glob": 0,
- "largest": 507,
+ "largest": 446,
"largest_file": "src/sandbox/kata.rs",
- "lines": 1408,
+ "lines": 1282,
"overwide": 0,
"priv": 9,
"pub": 21,
@@ -332,9 +333,9 @@
"dead": 4,
"deadonly": 0,
"glob": 0,
- "largest": 655,
+ "largest": 596,
"largest_file": "src/shims/mod.rs",
- "lines": 655,
+ "lines": 596,
"overwide": 0,
"priv": 0,
"pub": 8,
@@ -344,9 +345,9 @@
"dead": 3,
"deadonly": 0,
"glob": 0,
- "largest": 245,
+ "largest": 231,
"largest_file": "src/time.rs",
- "lines": 245,
+ "lines": 231,
"overwide": 0,
"priv": 0,
"pub": 13,
@@ -356,9 +357,9 @@
"dead": 0,
"deadonly": 0,
"glob": 0,
- "largest": 56,
+ "largest": 53,
"largest_file": "src/urlutil.rs",
- "lines": 56,
+ "lines": 53,
"overwide": 0,
"priv": 0,
"pub": 1,
@@ -368,9 +369,9 @@
"dead": 0,
"deadonly": 0,
"glob": 0,
- "largest": 124,
+ "largest": 112,
"largest_file": "src/usecase/reviews.rs",
- "lines": 405,
+ "lines": 346,
"overwide": 0,
"priv": 0,
"pub": 30,
@@ -380,9 +381,9 @@
"dead": 4,
"deadonly": 0,
"glob": 0,
- "largest": 296,
+ "largest": 272,
"largest_file": "src/watch/upstream.rs",
- "lines": 1115,
+ "lines": 1021,
"overwide": 0,
"priv": 12,
"pub": 21,
@@ -433,21 +434,20 @@
},
"test_surface": {
"already-gated": 28,
- "interface": 1,
"narrowed": 7,
- "total": 36
+ "total": 35
},
"totals": {
- "dead": 49,
+ "dead": 48,
"deadonly": 0,
"edges": 87,
"glob": 0,
- "largest": 699,
+ "largest": 650,
"largest_file": "src/config.rs",
- "lines": 15671,
+ "lines": 14644,
"overwide": 0,
"priv": 117,
"pub": 448,
- "test": 49
+ "test": 48
}
-}
+} \ No newline at end of file
diff --git a/tests/architecture.rs b/tests/architecture.rs
index 7159b32..55d80a5 100644
--- a/tests/architecture.rs
+++ b/tests/architecture.rs
@@ -1,31 +1,16 @@
-//! The layer map, in one place, checked on every test run.
+//! The layer map and the interface budgets, checked on every test run.
//!
-//! `tests/layers.rs` grew four greps for four mistakes. Four greps cannot say
-//! what the architecture *is*, cannot tell you where a new module belongs, and
-//! say nothing at all about the modules nobody has tripped over yet. This
-//! declares the whole map instead: every module in `src/` gets a rank, and a
-//! module may name only modules ranked strictly below it. One rule, every
-//! module, and the direction of dependence is written down rather than
-//! remembered.
-//!
-//! The same file holds the interface budgets. An interface is only as narrow as
-//! the items a module hands out, so each module is budgeted on how many `pub`
-//! items it declares and how many of them nothing outside the module ever
-//! names. Budgets live in `architecture-budget.json` and may only shrink: a
-//! number that grows fails the suite, and a number that has quietly got smaller
-//! has to be written back at the lower value, which is what stops a widening
-//! being mistaken for progress.
-//!
-//! `tools/arch-census.py` computes the same numbers for a human to read.
-//! `the_census_tool_and_this_test_agree` is the seam between them.
+//! Every module in `src/` gets a rank and may name only modules ranked strictly
+//! below it. Each module is budgeted on how many `pub` items it declares and how
+//! many of them nothing outside the module names; budgets live in
+//! `architecture-budget.json` and may only shrink. `tools/arch-census.py` computes
+//! the same numbers for a human to read.
use std::collections::{BTreeMap, BTreeSet};
use std::path::{Path, PathBuf};
-/// A module may name only modules ranked strictly below it. The order is the
-/// dependency graph itself, so each rank is written with the reason it sits
-/// there — a bare number invites someone to slot a module in wherever it is
-/// convenient.
+/// A module may name only modules ranked strictly below it; each rank is written
+/// with the reason it sits there.
const RANKS: &[(&str, u8, &str)] = &[
("error", 0, "the crate's error type: nothing in the crate is beneath it"),
("hash", 1, "sha256 and canonical json: pure"),
@@ -58,10 +43,6 @@ const RANKS: &[(&str, u8, &str)] = &[
];
/// `pub use … ::*` a module is still allowed to keep, as `module -> count`.
-/// This is the allowlist, and the ratchet is what empties it: a glob re-export
-/// flattens a namespace so a reader cannot see a module's width from its
-/// exports, which is the whole point of the budgets. `db` used to need two; it
-/// now names every export, so the slot is closed rather than left at zero.
const GLOB_ALLOWLIST: &[(&str, usize)] = &[("http", 2)];
const DECL_KEYWORDS: [&str; 7] = ["fn", "struct", "enum", "trait", "const", "static", "type"];
@@ -101,9 +82,7 @@ fn test_files() -> Vec<PathBuf> {
}
/// The module a file belongs to: a directory is one module, a top-level file is
-/// a module of its own, and a binary keeps its own name. A map that lumped
-/// eleven unrelated top-level files into one box could not say anything about
-/// any of them.
+/// a module of its own, and a binary keeps its own name.
fn module_of(path: &Path) -> String {
let rel = path.strip_prefix(src_root()).unwrap();
let parts: Vec<String> = rel.components().map(|c| c.as_os_str().to_string_lossy().into_owned()).collect();
@@ -270,9 +249,8 @@ impl Census {
}
let used_by_tests = test_texts.iter().any(|t| mentions(t, name));
for module in declaring {
- // An item the budget file argues for is a decision, not a hole,
- // so it leaves the dead columns entirely. `deadonly` then means
- // *dead and unargued* — the one number that can stay at zero.
+ // An item the budget file argues for leaves the dead columns,
+ // so `deadonly` means dead *and unargued*.
if allowlist.contains(&format!("{module}.{name}")) {
continue;
}
@@ -287,12 +265,8 @@ impl Census {
}
// A `pub(crate)` item is over-wide when no file except the one that
- // declares it writes its name: it offers the crate a thing nothing
- // outside its own file reaches, and plain private is what it should be.
- // `tests/` is not consulted — a separate crate cannot name a `pub(crate)`
- // item, so a mention there says nothing. As with `dead`, a name declared
- // in several files is flagged only when no file outside all of them says
- // it, and the compiler, not this count, gives the verdict.
+ // declares it names it. `tests/` is not consulted: a separate crate
+ // cannot name a `pub(crate)` item.
let mut pc_declared: BTreeMap<String, BTreeSet<PathBuf>> = BTreeMap::new();
for (path, text) in &texts {
for line in text.lines() {
@@ -309,8 +283,7 @@ impl Census {
}
for path in files {
let module = module_of(path);
- // Argued, so not counted: the reason it stays `pub(crate)` is in
- // the budget file next to its name, exactly as on the `pub` side.
+ // Argued in the budget file, so not counted.
if over_allow.contains(&format!("{module}.{name}")) {
continue;
}
@@ -477,9 +450,8 @@ fn dependence_only_points_downward() {
#[test]
fn the_map_admits_no_cycle() {
- // Strictly downward edges make a cycle impossible by construction, which is
- // the whole trick — so this asserts the property the map is trusted for,
- // over the edges that actually exist, rather than trusting the ranks.
+ // Strictly downward edges make a cycle impossible; this checks the edges
+ // that exist rather than trusting the ranks.
let census = Census::take();
let mut offenders = Vec::new();
for (source, targets) in &census.edges {
@@ -529,11 +501,8 @@ fn budgeted(row: &Module) -> [(&'static str, usize); 5] {
#[test]
fn interfaces_stay_within_budget() {
- // A `pub` item with no reader outside its module is not an interface, it is
- // a hole: a thing a caller may depend on and a thing a later refactor cannot
- // change without a grep across the crate. Zero holes is the destination, not
- // the starting point, so the rule is the ratchet — `deadonly` is how many
- // holes a module still has, and the only direction it may move is down.
+ // A `pub` item nobody outside its module reads is a hole, not an interface;
+ // `deadonly` counts them and may only move down.
let census = Census::take();
let budget = Census::budget();
let mut over = Vec::new();
@@ -562,8 +531,7 @@ fn interfaces_stay_within_budget() {
#[test]
fn a_shrunk_interface_is_written_back() {
- // The ratchet cuts both ways. A stale, generous budget is how a later
- // widening slips through unnoticed, so the file has to say what is true.
+ // A stale, generous budget is how a widening slips through unnoticed.
let census = Census::take();
let budget = Census::budget();
let mut stale = Vec::new();
@@ -587,9 +555,9 @@ fn a_shrunk_interface_is_written_back() {
#[test]
fn the_census_tool_and_this_test_agree() {
- // Two implementations of one definition will drift, and a drift means the
- // ratchet is measuring the wrong thing. Gated the way the vercmp oracle is:
- // without python3 the note prints and the suite moves on.
+ // Two implementations of one definition drift, and a drift means the ratchet
+ // measures the wrong thing. Without python3 the note prints and the suite
+ // moves on.
let available = std::process::Command::new("python3").arg("--version").output().is_ok();
if !available {
println!("python3 is not on PATH — skipping the census cross-check");
@@ -639,23 +607,15 @@ fn the_census_tool_and_this_test_agree() {
/// Every `pub` item that exists only because a test names it has a recorded
/// disposition, and the counts may only shrink.
///
-/// `tools/test-surface.py` asks two questions the census cannot: whether a test
-/// actually *calls* the item or merely mentions it inside a string, and whether
-/// production code inside the declaring module calls it. The answers yield four
-/// dispositions — `gate`, `move-test`, `narrow`, `residue` — and this test holds
-/// the crate to them in three ways:
-///
-/// - every row must carry a hand-written reason from
-/// `tools/test-surface-reasons.json`, so no item is disposed of by a heuristic
-/// nobody read;
-/// - the per-disposition counts, and `gate_pending` — items decided to be gated
-/// but not yet gated — may only shrink against the budget.
+/// `tools/test-surface.py` decides whether a test calls the item or merely
+/// mentions it in a string, and whether production inside the module calls it;
+/// the answers are the four dispositions `gate`, `move-test`, `narrow` and
+/// `residue`. Every row carries a hand-written reason from
+/// `tools/test-surface-reasons.json`.
///
-/// `residue` is the honest column: items production needs inside their own module
-/// *and* a fixture-bound integration test needs from outside. Rust has no
-/// test-conditional visibility, so those cannot be narrowed without breaking one
-/// side or the other; ratcheting the count is what keeps the column from growing
-/// while it is worked down by changing tests rather than visibilities.
+/// `residue` is the honest column: production needs the item inside its module
+/// and a fixture-bound test needs it from outside, and Rust has no
+/// test-conditional visibility.
#[test]
fn the_test_surface_is_disposed_of() {
if !std::process::Command::new("python3").arg("--version").output().is_ok() {
@@ -681,11 +641,8 @@ fn the_test_surface_is_disposed_of() {
if !row.get("hand_written").and_then(serde_json::Value::as_bool).unwrap_or(false) {
unreasoned.push(format!("{module}.{name} ({disp})"));
}
- // Every piece of in-module evidence for this item is a call in method
- // position on some receiver. A name match cannot tell `self.store_dir()`
- // from `listener.local_addr()` — the latter is std's, on a different
- // type, and it once made a function with no callers look production-used.
- // So these rows are named for a human and stay failing until confirmed.
+ // A name match cannot tell `self.store_dir()` from std's
+ // `listener.local_addr()`; ambiguous rows are named for a human.
if row.get("dotted_only").and_then(serde_json::Value::as_bool).unwrap_or(false)
&& disp != "already-gated"
&& !row.get("confirmed").and_then(serde_json::Value::as_bool).unwrap_or(false)
@@ -712,11 +669,8 @@ 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.
+ // A row is `ambiguous` when the only evidence is a bare mention of a
+ // name the detector cannot resolve, so a human records the verdict.
let mut unadjudicated = Vec::new();
for row in rows {
if row.get("ambiguous").and_then(serde_json::Value::as_bool).unwrap_or(false)
@@ -767,20 +721,14 @@ fn the_test_surface_is_disposed_of() {
);
}
-/// 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.
+/// The definitive check: 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. It asks the compiler what a release build
+/// actually lets an outside crate reach, rather than inferring it from source.
///
-/// `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`.
+/// `#[ignore]`d because it builds the library twice. 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() {
@@ -799,12 +747,8 @@ fn the_release_build_exports_nothing_that_only_tests_reach() {
}
/// The `dead_code.allowlist` is a set of decisions, so it has to stay in step
-/// with the code in both directions.
-///
-/// An entry that names nothing is the dangerous direction: it is an excuse that
-/// outlived the item it excused, and the next item to appear under that name
-/// inherits a permission nobody granted. The other direction — a blank reason —
-/// is an entry nobody read, which is the same thing as no entry.
+/// with the code in both directions: an entry naming nothing is an excuse that
+/// outlived its item, and a blank reason is an entry nobody read.
#[test]
fn the_dead_code_allowlist_names_real_items() {
let path = root().join("tests/architecture-budget.json");
@@ -816,9 +760,8 @@ fn the_dead_code_allowlist_names_real_items() {
.and_then(|a| a.as_object())
.expect("budget file has a dead_code.allowlist object");
- // Every name a module declares, `pub` or `pub(crate)`: a narrowed item keeps
- // its entry (the reason it is not named from outside still holds), an item
- // that no longer exists does not.
+ // Every name a module declares, `pub` or `pub(crate)`: a narrowed item
+ // keeps its entry, a vanished item does not.
let mut declared: BTreeMap<String, BTreeSet<String>> = BTreeMap::new();
for path in src_files() {
let module = module_of(&path);
@@ -866,15 +809,10 @@ fn the_dead_code_allowlist_names_real_items() {
);
}
-/// The `over_visibility.allowlist` is a set of decisions too, and it is checked
-/// the same two ways: an entry must name something that is still `pub(crate)` in
-/// the module it names, and it must carry a reason worth reading.
-///
-/// The first direction matters more here than on the `pub` side. A `pub(crate)`
-/// item that has since gone private still matches a `module.item` key written
-/// against the module's declared names, so the check has to look at the
-/// `pub(crate)` declarations specifically — otherwise the permission quietly
-/// re-widens the item it was left behind by.
+/// The `over_visibility.allowlist` is checked the same two ways. The direction
+/// that matters here: a `pub(crate)` item that has since gone private still
+/// matches a `module.item` key written against declared names, so the check
+/// looks at `pub(crate)` declarations specifically.
#[test]
fn the_over_visibility_allowlist_names_real_items() {
let path = root().join("tests/architecture-budget.json");
@@ -927,20 +865,9 @@ fn the_over_visibility_allowlist_names_real_items() {
}
/// `tests/common/mod.rs` is compiled into every test binary, so the suite keeps
-/// a crate-level `allow(dead_code)` there — a helper used by one binary is dead
-/// code in the other twenty, and the lint would fire everywhere and mean
-/// nothing. That allowance is only honest if nothing is unused by *all* of them,
-/// which is what this checks.
-///
-/// A name is used if anything under `tests/` writes it besides its own
-/// declaration. A type whose name nobody writes is still used if a field or
-/// method of it is: `Web::raw_request` hands back a `Raw` no test names, and
-/// reading `.status` off it is a use of the type.
-///
-/// Private items are checked too. The blanket allowance in `tests/common`
-/// excuses a private helper exactly as thoroughly as a public one, and a
-/// private helper called by nothing is the harder case to notice, not the
-/// easier one.
+/// a crate-level `allow(dead_code)` there. That allowance is only honest if
+/// nothing is unused by *all* of them, which is what this checks — private
+/// helpers included, and a type whose members are read counts as used.
#[test]
fn the_test_helpers_are_used() {
let common = root().join("tests/common/mod.rs");
@@ -953,9 +880,8 @@ fn the_test_helpers_are_used() {
let lines: Vec<&str> = text.lines().collect();
let mut unused = Vec::new();
for (i, line) in lines.iter().enumerate() {
- // `pub` and private alike: the blanket `allow(dead_code)` at the top of
- // the file excuses both, so a private helper nobody calls is exactly as
- // dead as a public one, and just as invisible to the compiler here.
+ // The blanket allowance excuses `pub` and private alike, so a private
+ // helper nobody calls is just as dead and just as invisible.
let t = line.trim_start();
let indent = line.len() - t.len();
if indent > 4 {
@@ -1013,9 +939,8 @@ fn the_test_helpers_are_used() {
);
}
-/// A fixture no test names is a corpus entry nobody maintains: it still costs
-/// the copy every `env_with_fixture` performs on its way to failing, and it
-/// drifts silently because nothing notices it drifting.
+/// A fixture no test names still costs the copy every `env_with_fixture`
+/// performs, and drifts silently because nothing reads it.
#[test]
fn every_fixture_is_referenced() {
let corpus = root().join("testcorpus");
@@ -1038,14 +963,10 @@ fn every_fixture_is_referenced() {
}
/// The two places the budget states how many unargued dead items a module may
-/// have must say the same thing.
-///
-/// `modules.<m>.deadonly` is the ratchet `interfaces_stay_within_budget` reads;
-/// `dead_code.deadonly.<m>` is the one `tools/arch-census.py --budget` reads.
-/// They are written by the same invocation and disagree only if someone edited
-/// one by hand, which is exactly the moment a ratchet stops meaning anything.
-/// Both are zero, and zero is the point: an item that is dead, exported and
-/// unargued is not a budget question, it is a failure.
+/// have must say the same thing: `modules.<m>.deadonly` is what the ratchet
+/// reads, `dead_code.deadonly.<m>` is what `tools/arch-census.py --budget`
+/// reads. Both are zero: dead, exported and unargued is a failure, not a
+/// budget question.
#[test]
fn the_dead_code_budget_matches_the_code() {
let path = root().join("tests/architecture-budget.json");
@@ -1081,10 +1002,8 @@ fn the_dead_code_budget_matches_the_code() {
#[test]
fn the_over_visibility_budget_matches_the_code() {
- // The same self-consistency the dead-code budget is held to: the accepted
- // count, the number in the `modules` section, and the number the census
- // actually measures have to be one number, or the ratchet is checking a
- // figure nothing reads.
+ // The accepted count, the `modules` section and the measured number have to
+ // be one number, or the ratchet checks a figure nothing reads.
let path = root().join("tests/architecture-budget.json");
let value: serde_json::Value =
serde_json::from_str(&std::fs::read_to_string(&path).expect("read budget")).expect("budget is json");
@@ -1121,13 +1040,10 @@ fn the_over_visibility_budget_matches_the_code() {
);
}
-/// Two tools write one file, so neither may erase what the other owns.
-///
-/// `tools/arch-census.py` writes the module numbers and the accepted dead-code
-/// counts; `tools/test-surface.py` writes the test-surface counts; a human owns
-/// the allowlist. A rewrite that drops a section does not fail anything until
-/// the ratchet quietly stops checking that axis, so this runs both writers
-/// against a copy and fails if either section disappears.
+/// Two tools write one file, so neither may erase what the other owns: a
+/// dropped section fails nothing until the ratchet quietly stops checking that
+/// axis, so this runs both writers against a copy and fails if either section
+/// disappears.
#[test]
fn the_budget_writers_preserve_each_other() {
let source = std::fs::read_to_string(root().join("tests/architecture-budget.json")).expect("read budget");
diff --git a/tests/common/mod.rs b/tests/common/mod.rs
index 5194035..6d05c3b 100644
--- a/tests/common/mod.rs
+++ b/tests/common/mod.rs
@@ -1,9 +1,7 @@
-// Every test binary compiles this file, so a helper that one of them uses is
-// dead code in the other twenty — 46 of the items below warn that way, and an
-// item-scoped allowance on each would say the same thing 46 times. The check
-// that does the work is `the_test_helpers_are_used` in tests/architecture.rs:
-// it reads this file and fails on any item, `pub` or private, that no test
-// names, so the allowance hides noise and cannot hide dead weight.
+// Every test binary compiles this file, so a helper one of them uses is dead
+// code in the other twenty. `the_test_helpers_are_used` in tests/architecture.rs
+// fails on any item here that no test names, so the allowance below hides noise
+// but cannot hide dead weight.
#![allow(dead_code)]
use std::collections::HashMap;
@@ -131,11 +129,8 @@ impl Env {
self.cfg.hooks.shim_fail = Some(tool.to_string());
}
- /// Run a statement the library deliberately does not expose.
- ///
- /// Fixtures use this to put a row in a state production would take a long
- /// way to reach — forcing a risk level, say — rather than the library
- /// growing a public setter that exists only for tests.
+ /// Run a statement the library deliberately does not expose, so a fixture
+ /// can reach a state without the library growing a test-only setter.
pub fn execute(&self, sql: &str, params: &[P]) {
let c = rusqlite::Connection::open(self.cfg.db_path()).unwrap();
let refs: Vec<&dyn rusqlite::ToSql> = params
@@ -298,9 +293,8 @@ pub fn materialize_fixture(root: &Path, name: &str) -> Fixture {
copy_tree(&pristine.upstream2, &upstream2);
}
if pristine.path_dependent {
- // The recipe names directories this test owns, so the copied commit
- // still speaks the cache's paths. Rewrite the work tree and fold it into
- // the single commit rather than rebuilding the repo from nothing.
+ // The recipe names directories this test owns, so the copied commit has
+ // to speak the cache's paths.
for (fname, body) in &pristine.recipe_files {
std::fs::write(aur.join(fname), substitute(body, &subs)).unwrap();
}
@@ -349,8 +343,6 @@ fn read_corpus(name: &str) -> Corpus {
}
/// The fixture repos, built once per test binary rather than once per test.
-/// Everything in them is path-independent except a recipe that names its own
-/// directories, so a test copies the trees and only rewrites when it must.
#[derive(Clone)]
struct Pristine {
aur: PathBuf,
@@ -426,9 +418,8 @@ fn copy_tree(from: &Path, to: &Path) {
let entry = entry.unwrap();
let path = entry.path();
let name = entry.file_name();
- // A git lock is a claim, not content: it can appear in the listing and
- // vanish before the copy, and a copied `index.lock` would make the copy
- // refuse to run at all.
+ // A git lock is a claim, not content: a copied `index.lock` would make
+ // the copy refuse to run at all.
if name.to_string_lossy().ends_with(".lock") {
continue;
}
@@ -549,9 +540,8 @@ pub fn git(dir: &Path, args: &[&str]) -> String {
let out = std::process::Command::new("git")
.arg("-C")
.arg(dir)
- // No test is about git's own housekeeping, and a detached maintenance run
- // outlives the command that spawned it: it can repack or lock a repo
- // while another test is still copying it.
+ // A detached maintenance run outlives the command that spawned it and
+ // can repack or lock a repo another test is still copying.
.args(["-c", "maintenance.auto=false", "-c", "gc.auto=0"])
.args(args)
.env("GIT_AUTHOR_NAME", "t")
diff --git a/tests/config.rs b/tests/config.rs
index 86222a8..441d6fe 100644
--- a/tests/config.rs
+++ b/tests/config.rs
@@ -3,14 +3,6 @@ use std::process::Command;
use aur_build::config::Config;
-// What remains here needs a real directory or a real process: the root
-// resolution tests create and remove paths under target/, and the CLI tests
-// run the built binary. The parsing, validation and Debug-redaction tests
-// moved into src/config.rs, where they are unit tests of the module.
-//
-// The one thing they could not shed is `Config::load`'s signature: it takes a
-// directory, so even a pure parse needs a file on disk somewhere.
-
#[test]
fn a_relative_root_is_absolutized_once_and_never_doubled() {
let rel = PathBuf::from("target").join("config-root-test").join("runtime");
diff --git a/tests/kata.rs b/tests/kata.rs
index 271a36f..a5df56d 100644
--- a/tests/kata.rs
+++ b/tests/kata.rs
@@ -8,11 +8,6 @@ use aur_build::sandbox::kata::{KataBackend, LocalAgentProvisioner};
use aur_build::sandbox::{Cmd, SandboxBackend, SandboxSpec};
use common::{env_with_fixture, shim_dir};
-// What remains drives a real sandbox agent or a real fixture build. The two
-// tests that only asserted this module's own machinery — the container record a
-// lease provisions, and the TTL expiry of a sandbox that never dials in — moved
-// into src/sandbox/kata.rs, where that machinery is declared.
-
fn agent_sandbox_config() -> Config {
let tmp = tempfile::tempdir().unwrap();
std::fs::write(
diff --git a/tests/state_machine.rs b/tests/state_machine.rs
index d90bf20..465b8e1 100644
--- a/tests/state_machine.rs
+++ b/tests/state_machine.rs
@@ -5,11 +5,6 @@ use aur_build::db::{
model::{BuildState, CandidateState, StepState},
};
use common::Env;
-// What remains all moves real rows through real transitions against a
-// database. The two tests that were only about the state enum — the column-text
-// round trip and the shape of the transition table — moved into
-// src/db/model/build_state.rs, where the enum and its table are declared, and
-// so did the one pure table assertion that a fixture test was making.
fn build(env: &Env, id: &str) -> String {
env.exec(
diff --git a/tests/versions.rs b/tests/versions.rs
index a7b41f8..b111e61 100644
--- a/tests/versions.rs
+++ b/tests/versions.rs
@@ -8,12 +8,6 @@ use aur_build::pkgver;
use aur_build::review::{candidates, diff};
use common::*;
-// What remains here is what a unit test cannot be: both tests build a real
-// package, publish it, and then move its upstream, so they need the fixture
-// harness and a database. The pure comparison vectors, the chunk rule, the
-// epoch rules and the dependency grammar all moved into src/pkgver/mod.rs,
-// where they are unit tests of the module rather than consumers of it.
-
#[test]
fn a_downgrade_in_the_aur_is_flagged_not_silently_served() {
let (env, fx) = env_with_fixture("plain-make");
@@ -49,8 +43,6 @@ fn an_epoch_bump_is_an_upgrade_even_though_the_version_went_down() {
assert!(!version.body.contains("DOWNGRADE"), "an epoch bump must not read as a downgrade: {:?}", version.body);
}
-// --- helpers -------------------------------------------------------------
-
fn publish(env: &Env, name: &str) {
let c = detect_raw(env, name);
let dd = diff::render_and_store(&env.db, &env.cfg, &c).unwrap();