diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/review/diff.rs | 13 | ||||
| -rw-r--r-- | src/shims/mod.rs | 7 | ||||
| -rw-r--r-- | src/time.rs | 11 |
3 files changed, 31 insertions, 0 deletions
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<String> { 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<serde_json::Value> { } } +/// 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<Option<String>> = 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<String> { CLOCK.with(|c| { let mut slot = c.borrow_mut(); @@ -44,6 +52,8 @@ pub fn pin(ts: &str) -> Option<String> { }) } +/// 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"); |
