diff options
| author | aur-build <aur-build@localhost> | 2026-11-20 23:39:07 +0000 |
|---|---|---|
| committer | aur-build <aur-build@localhost> | 2026-11-20 23:39:07 +0000 |
| commit | debb8af0ef0e72048b9df5fed40071745ea40c6b (patch) | |
| tree | 7cb37ad58cf8268b8e24530a384af95c8bd51b32 | |
| parent | c295510e2bb0ee61234536c832dad87a45977fc8 (diff) | |
| download | aur-build-debb8af0ef0e72048b9df5fed40071745ea40c6b.tar.gz aur-build-debb8af0ef0e72048b9df5fed40071745ea40c6b.zip | |
sandbox,http,review,watch: keep six more test-only types out of the release build
| -rw-r--r-- | src/http/render.rs | 82 | ||||
| -rw-r--r-- | src/http/sse.rs | 35 | ||||
| -rw-r--r-- | src/review/approve.rs | 41 | ||||
| -rw-r--r-- | src/sandbox/mod.rs | 27 | ||||
| -rw-r--r-- | src/watch/upstream.rs | 43 |
5 files changed, 165 insertions, 63 deletions
diff --git a/src/http/render.rs b/src/http/render.rs index 470125d..4482380 100644 --- a/src/http/render.rs +++ b/src/http/render.rs @@ -1,25 +1,42 @@ use askama::Template; -#[derive(Debug, Clone)] -pub struct Page { - pub title: String, - pub flash: String, - pub has_flash: bool, - pub flash_err: bool, - pub csrf: String, - pub pending: i64, - pub running: i64, - pub attention: i64, - pub nav_reviews: &'static str, - pub nav_builds: &'static str, - pub nav_attention: &'static str, - pub nav_packages: &'static str, - pub nav_subscriptions: &'static str, - pub nav_audit: &'static str, - pub nav_settings: &'static str, - pub gated: bool, +/// The real definition. The module is private, so this `pub` +/// is not a nameable path from outside; the alias below is the +/// only way to reach it, and the alias is what carries the +/// feature-conditional visibility. +mod page { + #[derive(Debug, Clone)] + pub struct Page { + pub title: String, + pub flash: String, + pub has_flash: bool, + pub flash_err: bool, + pub csrf: String, + pub pending: i64, + pub running: i64, + pub attention: i64, + pub nav_reviews: &'static str, + pub nav_builds: &'static str, + pub nav_attention: &'static str, + pub nav_packages: &'static str, + pub nav_subscriptions: &'static str, + pub nav_audit: &'static str, + pub nav_settings: &'static str, + pub gated: bool, + } } +/// The render model's shared header. Every template and route handler that fills it lives inside `http`; the outside readers are the page tests. +/// +/// `pub` only under `test-support`. Production reaches the type +/// through its own module and never names it from outside; the +/// outside reader that needs the name is a test. +#[cfg(feature = "test-support")] +pub use page::Page; + +#[cfg(not(feature = "test-support"))] +pub(crate) use page::Page; + impl Page { pub fn new(title: &str, csrf: String) -> Self { Self { @@ -138,14 +155,31 @@ pub(crate) struct ReviewHead { pub diff_digest: String, } -#[derive(Debug, Clone)] -pub struct Panel { - pub title: String, - pub body: String, - pub empty: bool, - pub empty_note: String, +/// The real definition. The module is private, so this `pub` +/// is not a nameable path from outside; the alias below is the +/// only way to reach it, and the alias is what carries the +/// feature-conditional visibility. +mod panel { + #[derive(Debug, Clone)] + pub struct Panel { + pub title: String, + pub body: String, + pub empty: bool, + pub empty_note: String, + } } +/// A diff panel in the render model. The tests that assert on its body drive a real review and cannot move into the module. +/// +/// `pub` only under `test-support`. Production reaches the type +/// through its own module and never names it from outside; the +/// outside reader that needs the name is a test. +#[cfg(feature = "test-support")] +pub use panel::Panel; + +#[cfg(not(feature = "test-support"))] +pub(crate) use panel::Panel; + impl Panel { pub fn new(title: &str, body: String) -> Self { Self { diff --git a/src/http/sse.rs b/src/http/sse.rs index bceba9f..98e9282 100644 --- a/src/http/sse.rs +++ b/src/http/sse.rs @@ -8,17 +8,34 @@ const MAX_LIFETIME: Duration = Duration::from_secs(30 * 60); const KEEPALIVE: Duration = Duration::from_secs(10); const POLL: Duration = Duration::from_millis(200); -pub struct LogTail { - path: PathBuf, - build_id: String, - db: crate::db::Db, - offset: u64, - out: std::collections::VecDeque<u8>, - started: Instant, - since_keepalive: Duration, - ended: bool, +/// The real definition. The module is private, so this `pub` +/// is not a nameable path from outside; the alias below is the +/// only way to reach it, and the alias is what carries the +/// feature-conditional visibility. +mod log_tail { + pub struct LogTail { + path: PathBuf, + build_id: String, + db: crate::db::Db, + offset: u64, + out: std::collections::VecDeque<u8>, + started: Instant, + since_keepalive: Duration, + ended: bool, + } } +/// The SSE tail handle. The live test that names it drives a real server, so it cannot move into the module. +/// +/// `pub` only under `test-support`. Production reaches the type +/// through its own module and never names it from outside; the +/// outside reader that needs the name is a test. +#[cfg(feature = "test-support")] +pub use log_tail::LogTail; + +#[cfg(not(feature = "test-support"))] +pub(crate) use log_tail::LogTail; + impl LogTail { pub fn new(cfg: &crate::config::Config, db: crate::db::Db, build_id: &str) -> Self { Self { diff --git a/src/review/approve.rs b/src/review/approve.rs index 82812fb..f277ac5 100644 --- a/src/review/approve.rs +++ b/src/review/approve.rs @@ -151,20 +151,37 @@ pub enum BulkOutcome { Refused(BulkRefusal), } -#[derive(Debug, thiserror::Error)] -pub enum BulkRefusal { - #[error("high risk: confirm it individually")] - HighRiskUnconfirmed, - #[error("unknown decision `{0}`")] - UnknownDecision(String), - #[error("no such review")] - NotFound, - #[error(transparent)] - Stale(Stale), - #[error("{0}")] - System(Error), +/// The real definition. The module is private, so this `pub` +/// is not a nameable path from outside; the alias below is the +/// only way to reach it, and the alias is what carries the +/// feature-conditional visibility. +mod bulk_refusal { + #[derive(Debug, thiserror::Error)] + pub enum BulkRefusal { + #[error("high risk: confirm it individually")] + HighRiskUnconfirmed, + #[error("unknown decision `{0}`")] + UnknownDecision(String), + #[error("no such review")] + NotFound, + #[error(transparent)] + Stale(Stale), + #[error("{0}")] + System(Error), + } } +/// The payload of one `BulkOutcome::Refused` arm. The bulk tests construct it to assert which approval was refused. +/// +/// `pub` only under `test-support`. Production reaches the type +/// through its own module and never names it from outside; the +/// outside reader that needs the name is a test. +#[cfg(feature = "test-support")] +pub use bulk_refusal::BulkRefusal; + +#[cfg(not(feature = "test-support"))] +pub(crate) use bulk_refusal::BulkRefusal; + pub fn bulk( db: &Db, actor: &str, diff --git a/src/sandbox/mod.rs b/src/sandbox/mod.rs index 6c90f7f..ded76f0 100644 --- a/src/sandbox/mod.rs +++ b/src/sandbox/mod.rs @@ -73,13 +73,30 @@ impl SandboxSpec { } } -#[derive(Debug, Clone)] -pub struct SandboxInfo { - pub id: String, - pub profile: String, - pub warm: bool, +/// The real definition. The module is private, so this `pub` +/// is not a nameable path from outside; the alias below is the +/// only way to reach it, and the alias is what carries the +/// feature-conditional visibility. +mod sandbox_info { + #[derive(Debug, Clone)] + pub struct SandboxInfo { + pub id: String, + pub profile: String, + pub warm: bool, + } } +/// The return type of `SandboxBackend::status`. No production module outside `sandbox` names it; the backend tests do. +/// +/// `pub` only under `test-support`. Production reaches the type +/// through its own module and never names it from outside; the +/// outside reader that needs the name is a test. +#[cfg(feature = "test-support")] +pub use sandbox_info::SandboxInfo; + +#[cfg(not(feature = "test-support"))] +pub(crate) use sandbox_info::SandboxInfo; + pub trait Sandbox: Send + Sync { fn id(&self) -> &str; fn run(&self, cmd: &Cmd, on_log: &mut dyn FnMut(&[u8])) -> Result<Exit>; diff --git a/src/watch/upstream.rs b/src/watch/upstream.rs index c3e4954..888a5ed 100644 --- a/src/watch/upstream.rs +++ b/src/watch/upstream.rs @@ -143,25 +143,42 @@ static RUNNING: AtomicUsize = AtomicUsize::new(0); static SLOT_FREE: Condvar = Condvar::new(); static SLOT_LOCK: Mutex<()> = Mutex::new(()); -pub struct StageBSlot(()); +/// The real definition. The module is private, so this `pub` +/// is not a nameable path from outside; the alias below is the +/// only way to reach it, and the alias is what carries the +/// feature-conditional visibility. +mod stage_b_slot { + pub struct StageBSlot(()); -impl StageBSlot { - pub fn acquire(cap: usize) -> Self { - let cap = cap.max(1); - let guard = SLOT_LOCK.lock().unwrap_or_else(|e| e.into_inner()); - let mut guard = guard; - loop { - let n = RUNNING.load(Ordering::SeqCst); - if n < cap { - RUNNING.fetch_add(1, Ordering::SeqCst); - drop(guard); - return StageBSlot(()); + impl StageBSlot { + pub fn acquire(cap: usize) -> Self { + let cap = cap.max(1); + let guard = SLOT_LOCK.lock().unwrap_or_else(|e| e.into_inner()); + let mut guard = guard; + loop { + let n = RUNNING.load(Ordering::SeqCst); + if n < cap { + RUNNING.fetch_add(1, Ordering::SeqCst); + drop(guard); + return StageBSlot(()); + } + guard = SLOT_FREE.wait(guard).unwrap_or_else(|e| e.into_inner()); } - guard = SLOT_FREE.wait(guard).unwrap_or_else(|e| e.into_inner()); } } } +/// The stage-B concurrency slot. The VCS test that asserts it needs a real mirror, so it cannot move into the module. +/// +/// `pub` only under `test-support`. Production reaches the type +/// through its own module and never names it from outside; the +/// outside reader that needs the name is a test. +#[cfg(feature = "test-support")] +pub use stage_b_slot::StageBSlot; + +#[cfg(not(feature = "test-support"))] +pub(crate) use stage_b_slot::StageBSlot; + impl Drop for StageBSlot { fn drop(&mut self) { RUNNING.fetch_sub(1, Ordering::SeqCst); |
