diff options
| author | aur-build <aur-build@localhost> | 2026-11-22 10:44:04 +0000 |
|---|---|---|
| committer | aur-build <aur-build@localhost> | 2026-11-22 10:44:04 +0000 |
| commit | 1e1e12e7220a3fd288782ae40f0823db32acf6cb (patch) | |
| tree | 1e436bfbe305cbeccee93758e67d1ca11e3096e6 /src/time.rs | |
| parent | 3dc71b2f5160ef9bd46143eed0edb5d2557b58e6 (diff) | |
| download | aur-build-1e1e12e7220a3fd288782ae40f0823db32acf6cb.tar.gz aur-build-1e1e12e7220a3fd288782ae40f0823db32acf6cb.zip | |
src,tests: say each thing once, in the code or not at all
The repeated explanations go: sixteen copies of why a `pub` under
`test-support` has two declarations, six notes about where a test moved
from, forty-three banner comments naming the section they sit above.
The prose that stays is the prose the code cannot say — a hand-written
Debug that keeps a token out of a log line, a git pipe that would
deadlock if the write came first, an end-of-string check that has to
precede the separator skip. Enum docs in error.rs collapse to the line
that names what the type is; the argument for why it is shaped that way
is in the variants.
Diffstat (limited to 'src/time.rs')
| -rw-r--r-- | src/time.rs | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/src/time.rs b/src/time.rs index 4abb3f9..a05c0e7 100644 --- a/src/time.rs +++ b/src/time.rs @@ -39,11 +39,8 @@ thread_local! { /// 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. +/// Gated with `unpin`: they are one capability, and gating half would leave a +/// release binary able to freeze time and unable to release it. #[cfg(feature = "test-support")] pub fn pin(ts: &str) -> Option<String> { CLOCK.with(|c| { @@ -52,7 +49,7 @@ pub fn pin(ts: &str) -> Option<String> { }) } -/// Release a pin set by `pin`. See the note there about why both are gated. +/// Release a pin set by `pin`. #[cfg(feature = "test-support")] pub fn unpin() { CLOCK.with(|c| *c.borrow_mut() = None); @@ -76,8 +73,6 @@ pub fn secs_ahead(secs: i64) -> String { fmt(base() + chrono::Duration::seconds(secs)) } -// ---- waiting ---- - /// Wait for `d`, checking `stop` every `slice`. Returns false if `stop` was set /// before the wait finished, so a control loop can leave instead of doing one /// more pass. @@ -105,8 +100,8 @@ pub fn sleep(d: Duration) { } /// Wrap a closure about to be spawned so the child thread inherits this one's -/// clock setting. Without it a control loop spawned by a test runs on wall time -/// while the test itself runs on the virtual clock, and the two disagree. +/// clock setting; a spawned control loop on wall time would disagree with a +/// test on the virtual clock. pub fn inherit<F, T>(f: F) -> impl FnOnce() -> T where F: FnOnce() -> T + Send + 'static, @@ -138,7 +133,7 @@ mod clock { static AT: Mutex<Option<DateTime<Utc>>> = Mutex::new(None); static OWNER: Mutex<()> = Mutex::new(()); - // VirtualClock stays `pub`: lives in the `test-support`-gated clock module, behind the gated `virtualize()` that returns it. + // `pub` only because the gated `virtualize()` that returns it is `pub`. pub struct VirtualClock { // Held, never read: owning the mutex *is* the virtual clock's lease, // and dropping this guard is what releases it. @@ -216,10 +211,6 @@ mod clock { mod tests { use super::*; - // Moved verbatim from tests/time.rs. These two are arithmetic on the - // 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() { |
