From b3c326735e4c212afed8c6a25411a1040a67f760 Mon Sep 17 00:00:00 2001 From: aur-build Date: Fri, 20 Nov 2026 21:20:05 +0000 Subject: review, shims, time: gate the last three test-only entry points MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `review::diff::render_and_store` is the alarming row in the table: zero callers in `src/`, seventeen test files. Intake renders through `review::intake::record` — the single entry point the pipeline and both front ends use — and this is the older uncomposed form. It is gated, not relocated to `tests/common`, because it needs this module's private `panels`/`render_text` and `candidates::set_diff_digest`; widening those to let a test out would undo the narrowing the last dozen commits did. `shims::called_with` is gated: the shim *writes* its invocation log in production, which is how a fake tool leaves evidence, but nothing in the crate reads it back. Only tests ask what a build actually did. `time::pin` and `time::unpin` are gated together. Gating half of a two-function capability would leave a release binary able to freeze the clock and unable to release it. `pin` is worth naming because the census never reported it as test-only at all: its name match also fires inside `upstream_pins`, so a genuinely test-only function hid in plain sight until its counterpart was examined. The only callers in the crate are tests, and the unit test that uses them is gated with them. Nothing was relocated to `tests/common`. The table chose no `relocate` disposition — every item either needed module-private internals or moved into its own module instead — and no API was widened to accommodate a test, which was the condition on relocating anything. Test-only items across the crate: 61 at the start of this work, 46 now, of which 33 are residue and 13 already gated. `gate_pending` is zero. Suite: 284 passed, 0 failed, 0 ignored. Clippy clean. --- src/review/diff.rs | 13 +++++++++++++ src/shims/mod.rs | 7 +++++++ src/time.rs | 11 +++++++++++ 3 files changed, 31 insertions(+) (limited to 'src') diff --git a/src/review/diff.rs b/src/review/diff.rs index 4a8a3ef..39d9066 100644 --- a/src/review/diff.rs +++ b/src/review/diff.rs @@ -266,6 +266,19 @@ pub fn diff_digest(ps: &[Panel]) -> String { crate::hash::hex_str(&render_text(ps)) } +/// Render a candidate's diff, store its digest on the row, and return it. +/// +/// Test-tier only, and that is worth stating plainly because the number says +/// something alarming at first glance: zero callers in `src/`, seventeen test +/// files. Intake renders through `review::intake::record`, which is the single +/// entry point the pipeline and both front ends use; this is the older, +/// uncomposed form that says "render and store" in two steps. It stays because +/// a test that wants a digest without running intake wants exactly this, and it +/// is gated rather than moved to `tests/common` because it needs this module's +/// private `panels`/`render_text` and `candidates::set_diff_digest` — widening +/// those to let a test out would undo the narrowing this crate just spent a +/// dozen commits doing. +#[cfg(feature = "test-support")] pub fn render_and_store(db: &Db, cfg: &Config, c: &CandidateRow) -> Result { let base = match c.base_release_id { Some(id) => db::release_by_id(db, id)?, diff --git a/src/shims/mod.rs b/src/shims/mod.rs index debcd19..67c6640 100644 --- a/src/shims/mod.rs +++ b/src/shims/mod.rs @@ -141,6 +141,13 @@ pub fn invocations(dir: &Path) -> Vec { } } +/// How many times the shim recorded `tool` being called with `needle` in its +/// arguments. +/// +/// Test-tier only. The shim *writes* the invocation log in production — that is +/// how a fake tool leaves evidence — but nothing in the crate reads it back; +/// only tests ask what a build actually did. +#[cfg(feature = "test-support")] pub fn called_with(dir: &Path, tool: &str, needle: &str) -> usize { invocations(dir) .iter() diff --git a/src/time.rs b/src/time.rs index 5e82f0c..9917f54 100644 --- a/src/time.rs +++ b/src/time.rs @@ -37,6 +37,14 @@ thread_local! { static CLOCK: std::cell::RefCell> = const { std::cell::RefCell::new(None) }; } +/// Freeze the clock for this thread, returning the previous pin if any. +/// +/// Test-tier only, together with `unpin` — the two are one capability and +/// gating half of it would leave a release binary able to freeze time and +/// unable to release it. The census never reported `pin` as test-only because +/// its name match also fires inside `upstream_pins` and `source_digests`; the +/// only callers in the crate are tests. +#[cfg(feature = "test-support")] pub fn pin(ts: &str) -> Option { CLOCK.with(|c| { let mut slot = c.borrow_mut(); @@ -44,6 +52,8 @@ pub fn pin(ts: &str) -> Option { }) } +/// Release a pin set by `pin`. See the note there about why both are gated. +#[cfg(feature = "test-support")] pub fn unpin() { CLOCK.with(|c| *c.borrow_mut() = None); } @@ -212,6 +222,7 @@ mod tests { // clock itself and need nothing else; the third test in that file pins a // lease against a pinned clock, which needs a database, so it stayed. + #[cfg(feature = "test-support")] #[test] fn a_pinned_clock_moves_relative_arithmetic_with_it() { pin("2026-01-01T00:00:00Z"); -- cgit v1.2.3