summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraur-build <aur-build@localhost>2026-11-20 21:12:59 +0000
committeraur-build <aur-build@localhost>2026-11-20 21:12:59 +0000
commit72dcae2a04644609a30a90200edca368d131d600 (patch)
tree8eb16225659e4a977deeec38b29c94420ff256b0
parent2210c934d4a25602318f094e0eca72f42862d44a (diff)
downloadaur-build-72dcae2a04644609a30a90200edca368d131d600.tar.gz
aur-build-72dcae2a04644609a30a90200edca368d131d600.zip
http, config, sandbox: apply the rest of the dispositions
Five http items were being counted as test-pinned on the strength of a string alone, and are now `pub(crate)`: render::Attention the word appears in crash.rs inside a message Res::html "text/html" is a content type, not a call Res::redirect "redirect" appears in an assertion message routes::logout "/logout" is a route path routes::route "mutating route" appears in an assertion message Nothing in the test tier calls any of them; each carries a comment saying so, because "the census said a test needed this" is not a reason and will be re-asked by the next person to read the line. `config::TestHooks` was already half-gated — the `hooks` field and the `Default` line that fills it are both behind `test-support` — while the type and its impl were not, so a release binary compiled a struct it could never construct, read, or deserialize. Now gated whole. The live kata tier moved into `src/sandbox/kata.rs`. It is not a fixture test: it records its own absence without /dev/kvm or AUR_KATA_API, the same way the vercmp live tier does. It was the only thing outside the module naming `K8sSandboxProvisioner` field by field, so that struct is `pub(crate)` now too. One correction to the table, and it is the kind of correction a heuristic deserves: `http::cookie` and `http::login` were classified `move-test` because their tests contain no harness keyword. They do — `Web::` starts a real HTTP listener, and a test that talks to one is not a unit test however little code it holds. The detector now knows that, and both items are residue, which is what they always were. http: 27 pub -> 22 pub. Test-only items across the crate: 52 -> 46. Suite: 284 passed, 0 failed, 0 ignored. Clippy clean.
-rw-r--r--src/config.rs6
-rw-r--r--src/http/mod.rs6
-rw-r--r--src/http/render.rs3
-rw-r--r--src/http/routes/mod.rs6
-rw-r--r--src/sandbox/kata.rs35
-rw-r--r--tests/architecture-budget.json48
-rw-r--r--tests/kata.rs28
-rw-r--r--tools/test-surface.md44
-rw-r--r--tools/test-surface.py7
9 files changed, 92 insertions, 91 deletions
diff --git a/src/config.rs b/src/config.rs
index cd43b97..bb60cc7 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -133,6 +133,11 @@ pub struct Config {
pub dispatch_tick_secs: u64,
}
+/// Test-tier only, and already half-gated: the `hooks` field that holds one and
+/// the `Default` line that fills it are both behind `test-support`, so without
+/// the gate below this type compiles into a release binary that can never
+/// construct, read, or deserialize it.
+#[cfg(feature = "test-support")]
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default)]
pub struct TestHooks {
@@ -145,6 +150,7 @@ pub struct TestHooks {
pub shim_plant_link: Option<String>,
}
+#[cfg(feature = "test-support")]
impl TestHooks {
pub fn is_empty(&self) -> bool {
self.path_prepend.is_none()
diff --git a/src/http/mod.rs b/src/http/mod.rs
index 5c34466..a77869e 100644
--- a/src/http/mod.rs
+++ b/src/http/mod.rs
@@ -48,7 +48,8 @@ pub(crate) struct Res {
}
impl Res {
- pub fn html(status: u16, body: String) -> Self {
+ /// `pub(crate)`, not `pub`: the census counted it as test-only because the word appears in `tests/http.rs`, but only inside a string — a route path, a content type, the word "redirect" in an assertion message. Nothing in the test tier calls it.
+ pub(crate) fn html(status: u16, body: String) -> Self {
Self { status, content_type: "text/html; charset=utf-8".into(), body: body.into_bytes(), headers: Vec::new(), stream: None, stream_len: None }
}
pub fn text(status: u16, body: String) -> Self {
@@ -64,7 +65,8 @@ impl Res {
stream_len: known_len,
}
}
- pub fn redirect(location: &str) -> Self {
+ /// `pub(crate)`, not `pub`: the census counted it as test-only because the word appears in `tests/http.rs`, but only inside a string — a route path, a content type, the word "redirect" in an assertion message. Nothing in the test tier calls it.
+ pub(crate) fn redirect(location: &str) -> Self {
Self {
status: 303,
content_type: "text/plain".into(),
diff --git a/src/http/render.rs b/src/http/render.rs
index fdf5676..470125d 100644
--- a/src/http/render.rs
+++ b/src/http/render.rs
@@ -179,7 +179,8 @@ pub(crate) struct SubRow {
#[derive(Template)]
#[template(path = "attention.html")]
-pub struct Attention {
+/// `pub(crate)`, not `pub`: the census counted it as test-only because the word appears in `tests/http.rs`, but only inside a string — a route path, a content type, the word "redirect" in an assertion message. Nothing in the test tier calls it.
+pub(crate) struct Attention {
pub page: Page,
pub empty: bool,
pub notices: Vec<NoticeRow>,
diff --git a/src/http/routes/mod.rs b/src/http/routes/mod.rs
index 7495524..1ef7fde 100644
--- a/src/http/routes/mod.rs
+++ b/src/http/routes/mod.rs
@@ -33,7 +33,8 @@ pub(crate) fn login_form(state: &State, req: &Req) -> Res {
page_to_res(Login { page, error: String::new() }, 200)
}
-pub fn logout(req: &Req) -> Res {
+/// `pub(crate)`, not `pub`: the census counted it as test-only because the word appears in `tests/http.rs`, but only inside a string — a route path, a content type, the word "redirect" in an assertion message. Nothing in the test tier calls it.
+pub(crate) fn logout(req: &Req) -> Res {
if let Some(sid) = req.cookie("sid") {
auth::drop_session(&sid);
}
@@ -62,7 +63,8 @@ pub fn login(state: &State, req: &Req) -> Res {
}
}
-pub fn route(state: &State, req: &Req, seg: &[&str]) -> Res {
+/// `pub(crate)`, not `pub`: the census counted it as test-only because the word appears in `tests/http.rs`, but only inside a string — a route path, a content type, the word "redirect" in an assertion message. Nothing in the test tier calls it.
+pub(crate) fn route(state: &State, req: &Req, seg: &[&str]) -> Res {
match (req.method.as_str(), seg) {
("GET", []) => dashboard(state, req),
("GET", ["reviews"]) => reviews(state, req),
diff --git a/src/sandbox/kata.rs b/src/sandbox/kata.rs
index 66f7cba..26e9acc 100644
--- a/src/sandbox/kata.rs
+++ b/src/sandbox/kata.rs
@@ -83,7 +83,7 @@ impl K8sSandboxProvisioner {
}
}
-pub struct K8sSandboxProvisioner {
+pub(crate) struct K8sSandboxProvisioner {
pub api: String,
pub bearer: String,
pub namespace: String,
@@ -447,4 +447,37 @@ mod tests {
assert!(started.elapsed() >= Duration::from_millis(900), "acquire gave up before the TTL");
assert!(err.to_string().contains("never dialed in"), "{err}");
}
+
+ // ------------------------------------------------------------------
+ // Moved verbatim from tests/kata.rs. It is an opt-in live tier, not a
+ // fixture test: it records its own absence when there is no /dev/kvm or no
+ // AUR_KATA_API, exactly as the vercmp live tier does. It constructs the
+ // provisioner field by field, which is the only reason that struct was
+ // nameable from outside; with the test here, it no longer needs to be.
+ // ------------------------------------------------------------------
+
+ #[test]
+ fn the_live_kata_tier_is_recorded_not_silently_absent() {
+ if !std::path::Path::new("/dev/kvm").exists() {
+ println!("note: no /dev/kvm on this host; the live kata tier is skipped, not passed");
+ return;
+ }
+ let Ok(api) = std::env::var("AUR_KATA_API") else {
+ println!("note: /dev/kvm present but AUR_KATA_API unset; live kata tier still skipped");
+ return;
+ };
+ let cfg = Config::default();
+ let prov = Arc::new(K8sSandboxProvisioner {
+ api,
+ bearer: std::env::var("AUR_KATA_TOKEN").unwrap_or_default(),
+ namespace: std::env::var("AUR_KATA_NS").unwrap_or_else(|_| "default".into()),
+ });
+ let backend = KataBackend::bind(&cfg, "0.0.0.0:9443", &std::env::var("AUR_AGENT_TOKEN").unwrap(), prov).unwrap();
+ let sbx = backend
+ .acquire(&SandboxSpec::new("extra-x86_64", "live", Duration::from_secs(300)))
+ .expect("live kata sandbox should lease");
+ let out = sbx.run(&crate::sandbox::Cmd::new(["/bin/echo", "kata"]), &mut |_| {}).unwrap();
+ assert!(out.success() && String::from_utf8_lossy(&out.stdout).contains("kata"));
+ sbx.destroy().unwrap();
+ }
}
diff --git a/tests/architecture-budget.json b/tests/architecture-budget.json
index 0e9fd0a..fc44d5f 100644
--- a/tests/architecture-budget.json
+++ b/tests/architecture-budget.json
@@ -81,9 +81,9 @@
"dead": 2,
"deadonly": 0,
"glob": 0,
- "largest": 667,
+ "largest": 673,
"largest_file": "src/config.rs",
- "lines": 667,
+ "lines": 673,
"priv": 0,
"pub": 29,
"test": 2
@@ -144,15 +144,15 @@
"test": 0
},
"http": {
- "dead": 13,
+ "dead": 8,
"deadonly": 3,
"glob": 0,
"largest": 565,
"largest_file": "src/http/routes/pages.rs",
- "lines": 1922,
- "priv": 67,
- "pub": 27,
- "test": 10
+ "lines": 1927,
+ "priv": 72,
+ "pub": 22,
+ "test": 5
},
"lib": {
"dead": 0,
@@ -243,15 +243,15 @@
"test": 4
},
"sandbox": {
- "dead": 10,
+ "dead": 9,
"deadonly": 2,
"glob": 0,
- "largest": 451,
+ "largest": 484,
"largest_file": "src/sandbox/kata.rs",
- "lines": 1279,
- "priv": 15,
- "pub": 22,
- "test": 8
+ "lines": 1312,
+ "priv": 16,
+ "pub": 21,
+ "test": 7
},
"shims": {
"dead": 12,
@@ -310,25 +310,23 @@
}
},
"test_surface": {
- "already-gated": 9,
+ "already-gated": 10,
"gate": 3,
"gate_pending": 3,
- "move-test": 3,
- "narrow": 5,
- "residue": 32,
- "total": 52,
- "ungated": 43
+ "residue": 33,
+ "total": 46,
+ "ungated": 36
},
"totals": {
- "dead": 90,
+ "dead": 84,
"deadonly": 36,
"edges": 87,
"glob": 0,
- "largest": 667,
+ "largest": 673,
"largest_file": "src/config.rs",
- "lines": 15074,
- "priv": 113,
- "pub": 490,
- "test": 54
+ "lines": 15118,
+ "priv": 119,
+ "pub": 484,
+ "test": 48
}
}
diff --git a/tests/kata.rs b/tests/kata.rs
index a0c61fa..a87a800 100644
--- a/tests/kata.rs
+++ b/tests/kata.rs
@@ -1,6 +1,5 @@
mod common;
-use std::path::Path;
use std::sync::Arc;
use std::time::Duration;
@@ -55,33 +54,6 @@ fn a_provisioned_sandbox_rendezvous_and_runs_a_command() {
}
#[test]
-fn the_live_kata_tier_is_recorded_not_silently_absent() {
- if !Path::new("/dev/kvm").exists() {
- println!("note: no /dev/kvm on this host; the live kata tier is skipped, not passed");
- return;
- }
- let Ok(api) = std::env::var("AUR_KATA_API") else {
- println!("note: /dev/kvm present but AUR_KATA_API unset; live kata tier still skipped");
- return;
- };
- let cfg = Config::default();
- let prov = Arc::new(aur_build::sandbox::kata::K8sSandboxProvisioner {
- api,
- bearer: std::env::var("AUR_KATA_TOKEN").unwrap_or_default(),
- namespace: std::env::var("AUR_KATA_NS").unwrap_or_else(|_| "default".into()),
- });
- let backend = KataBackend::bind(&cfg, "0.0.0.0:9443", &std::env::var("AUR_AGENT_TOKEN").unwrap(), prov).unwrap();
- let sbx = backend
- .acquire(&SandboxSpec::new("extra-x86_64", "live", Duration::from_secs(300)))
- .expect("live kata sandbox should lease");
- let out = sbx.run(&Cmd::new(["/bin/echo", "kata"]), &mut |_| {}).unwrap();
- assert!(out.success() && String::from_utf8_lossy(&out.stdout).contains("kata"));
- sbx.destroy().unwrap();
-}
-
-
-
-#[test]
fn agent_sandbox_is_a_backend_not_a_fallthrough_to_loopback() {
let cfg = agent_sandbox_config();
let backend = aur_build::sandbox::backend_for(&cfg).unwrap();
diff --git a/tools/test-surface.md b/tools/test-surface.md
index 19890a1..cd6851e 100644
--- a/tools/test-surface.md
+++ b/tools/test-surface.md
@@ -54,36 +54,19 @@ shrink.
| `shims` | `called_with` | `src/shims/mod.rs:144` | `crash.rs`, `dispatch.rs`, `invariants.rs`, `kata.rs` … | reads the shim's invocation log, which only tests inspect. |
| `time` | `unpin` | `src/time.rs:47` | `time.rs` | the clock escape hatch; `pin`/`unpin` exist so a test can freeze time. Its only in-module mention is a unit test. |
-## Move the test into the module, then narrow — 3 items
+## Residue — `pub` because Rust has no test-conditional visibility — 33 items
| module | item | declared at | test files | why |
|---|---|---|---|---|
-| `http` | `cookie` | `src/http/mod.rs:36` | `common/mod.rs`, `http.rs` | the auth cookie helper; the tests that use it build no fixture, so they move into the module and it narrows. |
-| `http` | `login` | `src/http/routes/mod.rs:45` | `common/mod.rs`, `http.rs` | the login route handler; same — its tests are harness-free and move with it. |
-| `sandbox` | `K8sSandboxProvisioner` | `src/sandbox/kata.rs:86` | `kata.rs` | the kata provisioner impl; tests/kata.rs drives it directly. |
-
-## Narrow — no test actually calls it — 5 items
-
-| module | item | declared at | test files | why |
-|---|---|---|---|---|
-| `http` | `Attention` | `src/http/render.rs:182` | `crash.rs` | census false positive: named in crash.rs only inside a string. |
-| `http` | `html` | `src/http/mod.rs:51` | `http.rs` | census false positive: named in http.rs only inside a string. |
-| `http` | `logout` | `src/http/routes/mod.rs:36` | `http.rs` | census false positive: named in http.rs only inside a string. |
-| `http` | `redirect` | `src/http/mod.rs:67` | `http.rs` | census false positive: named in http.rs only inside a string. |
-| `http` | `route` | `src/http/routes/mod.rs:65` | `http.rs` | census false positive: named in http.rs only inside a string. |
-
-## Residue — `pub` because Rust has no test-conditional visibility — 32 items
-
-| module | item | declared at | test files | why |
-|---|---|---|---|---|
-| `config` | `TestHooks` | `src/config.rs:138` | `common/mod.rs`, `production_surface.rs` | the `hooks` field is already gated; the type and its impl are not, so they compile into a release build that can never read them. |
-| `config` | `store_dir` | `src/config.rs:351` | `invariants.rs` | the content-addressed store layout is used at config.rs:313 and :355; tests/invariants.rs pins it and needs a fixture. |
+| `config` | `store_dir` | `src/config.rs:357` | `invariants.rs` | the content-addressed store layout is used at config.rs:313 and :355; tests/invariants.rs pins it and needs a fixture. |
| `db` | `MIGRATIONS` | `src/db/migrations.rs:326` | `db.rs` | `db::migrate` iterates it at db/mod.rs:135; tests/db.rs asserts the list is ordered and complete. |
| `db` | `ReleaseState` | `src/db/model/state.rs:78` | `pipeline.rs` | a row type named by twenty sites inside db; tests/pipeline.rs names it while driving a real pipeline. |
| `db` | `cas_accepted_release` | `src/db/pkgbases.rs:84` | `db.rs` | the compare-and-set on the accepted-release pointer; nothing in production performs that CAS today, but it is the primitive `accepted_release_for` is paired with. |
| `http` | `LogTail` | `src/http/sse.rs:11` | `live.rs` | the SSE tail type; the live test that names it drives a real server. |
| `http` | `Page` | `src/http/render.rs:4` | `common/mod.rs` | the render model, named by twenty sites in http; tests/mod.rs asserts on it directly. |
| `http` | `Panel` | `src/http/render.rs:142` | `versions.rs` | a diff panel in the render model; tests/versions.rs asserts on its body. |
+| `http` | `cookie` | `src/http/mod.rs:36` | `common/mod.rs`, `http.rs` | the auth cookie helper; the tests that use it build no fixture, so they move into the module and it narrows. |
+| `http` | `login` | `src/http/routes/mod.rs:46` | `common/mod.rs`, `http.rs` | the login route handler; same — its tests are harness-free and move with it. |
| `ops` | `STAGING_GRACE_SECS` | `src/ops.rs:310` | `ops.rs` | the grace period the staging sweep applies at ops.rs:286; tests/ops.rs pins the value it must be. |
| `ops` | `build_success_rate` | `src/ops.rs:46` | `ops.rs` | computed inside the maintenance report at ops.rs:87; tests/ops.rs checks the arithmetic. |
| `ops` | `sweep_staging` | `src/ops.rs:332` | `ops.rs` | called by the maintenance pass at ops.rs:286; tests/ops.rs exercises it directly. |
@@ -109,10 +92,11 @@ shrink.
| `watch` | `probe` | `src/watch/upstream.rs:25` | `ops.rs`, `vcs.rs` | the upstream probe, called by detect.rs:95; tests/ops.rs and tests/vcs.rs both need a fixture. |
| `watch` | `sync_mirror` | `src/watch/mirror.rs:17` | `detect.rs` | the mirror sync, called by detect.rs:40; tests/detect.rs drives a real sync. |
-## Already gated — 9 items
+## Already gated — 10 items
| module | item | declared at | test files | why |
|---|---|---|---|---|
+| `config` | `TestHooks` | `src/config.rs:143` | `common/mod.rs`, `production_surface.rs` | the `hooks` field is already gated; the type and its impl are not, so they compile into a release build that can never read them. |
| `db` | `claim` | `src/db/builds/mod.rs:138` | `common/mod.rs`, `state_machine.rs`, `time.rs` | production leases with `claim_batch`; `claim` is called only by tests, so the release build need not compile it. |
| `db` | `set_setting` | `src/db/settings.rs:44` | `db.rs` | a settings writer with no production caller; `setting`/`setting_i64` readers are used, the setter is not. |
| `db` | `shutdown` | `src/db/mod.rs:264` | `common/mod.rs`, `crash.rs`, `dispatch.rs` | `Writer::shutdown` is never called by the server; tests use it to quiesce the writer thread. |
@@ -128,13 +112,11 @@ shrink.
| disposition | count |
|---|---|
| `gate` | 3 |
-| `move-test` | 3 |
-| `narrow` | 5 |
-| `residue` | 32 |
-| `already-gated` | 9 |
-| **total** | **52** |
-
-Of these, 43 are ungated today. Gating the `gate` rows and narrowing the
-`narrow` rows removes 8 items from the release build's public surface; the
-`move-test` rows remove 3 more and take their tests home with them.
+| `residue` | 33 |
+| `already-gated` | 10 |
+| **total** | **46** |
+
+Of these, 36 are ungated today. Gating the `gate` rows and narrowing the
+`narrow` rows removes 3 items from the release build's public surface; the
+`move-test` rows remove 0 more and take their tests home with them.
diff --git a/tools/test-surface.py b/tools/test-surface.py
index 7a89069..f51c26e 100644
--- a/tools/test-surface.py
+++ b/tools/test-surface.py
@@ -35,7 +35,12 @@ PUB_RE = re.compile(r"^\s*pub\s+(?:fn|struct|enum|trait|const|static|type)\s+([A
COMMENT = re.compile(r"^\s*(?://|//!|///)")
GATE = "test-support"
HARNESS = ("Env::new", "env_with_fixture", "Fixture", "tempdir", "Command::new",
- "fs::", "shim_dir", "corpus_root")
+ "fs::", "shim_dir", "corpus_root",
+ # `Web::` starts a real HTTP server; a test that talks to it is not a
+ # unit test however little code it contains. Missing this first made
+ # two http route handlers look movable when their tests were
+ # driving a live listener.
+ "Web::", "web.get", "web.post", "raw_request")
# Reasons that take argument to state; everything else is derived from the
# evidence the analysis already has.