summaryrefslogtreecommitdiffstats
path: root/src/watch/upstream.rs
diff options
context:
space:
mode:
authoraur-build <aur-build@localhost>2026-11-20 23:38:01 +0000
committeraur-build <aur-build@localhost>2026-11-20 23:38:01 +0000
commitc295510e2bb0ee61234536c832dad87a45977fc8 (patch)
treed9e73e141da7eb2b09e553998a1435ad023cc0ac /src/watch/upstream.rs
parent92ecaabd7c62d029eba239e95cc8a7d2520fe4a9 (diff)
downloadaur-build-c295510e2bb0ee61234536c832dad87a45977fc8.tar.gz
aur-build-c295510e2bb0ee61234536c832dad87a45977fc8.zip
sandbox: keep `Exit` out of the release build
`Exit` is the result of running a command in a sandbox. `pipeline` consumes it through `Sandbox::run` — `.success()`, `.stderr` — without ever writing the name, which is why the census called it dead outside `sandbox`. The type now lives in a private `mod exit` and reaches the world through an alias that is `pub` only under `test-support` and `pub(crate)` otherwise. A `pub` definition inside a private module is not a nameable path from outside, but it is visible enough to appear in a public trait signature, which is what makes this possible where a plain `pub(crate) struct` is not. Verified with an external crate: naming `aur_build::sandbox::Exit` in a release build is `error[E0603]: struct Exit is private`; with `test-support` it compiles.
Diffstat (limited to 'src/watch/upstream.rs')
-rw-r--r--src/watch/upstream.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/watch/upstream.rs b/src/watch/upstream.rs
index 002d72b..c3e4954 100644
--- a/src/watch/upstream.rs
+++ b/src/watch/upstream.rs
@@ -17,12 +17,40 @@ pub struct StageA {
}
impl StageA {
+ /// Detection consults it; the VCS test that asserts it needs a real mirror.
+ ///
+ /// Module-internal in a production build, `pub` only under `test-support`:
+ /// one body behind two visibility declarations, exactly one of which compiles.
+ #[cfg(feature = "test-support")]
pub fn needs_stage_b(&self) -> bool {
+ Self::needs_stage_b_impl(self)
+ }
+
+ #[cfg(not(feature = "test-support"))]
+ pub(crate) fn needs_stage_b(&self) -> bool {
+ Self::needs_stage_b_impl(self)
+ }
+
+ fn needs_stage_b_impl(&self) -> bool {
self.moved || !self.unprobed.is_empty()
}
}
+/// Detection calls it on every expensive poll; the tests that pin it need a fixture.
+///
+/// Module-internal in a production build, `pub` only under `test-support`:
+/// one body behind two visibility declarations, exactly one of which compiles.
+#[cfg(feature = "test-support")]
pub fn probe(recipe: &Recipe, accepted: &[UpstreamPin]) -> Result<StageA> {
+ probe_impl(recipe, accepted)
+}
+
+#[cfg(not(feature = "test-support"))]
+pub(crate) fn probe(recipe: &Recipe, accepted: &[UpstreamPin]) -> Result<StageA> {
+ probe_impl(recipe, accepted)
+}
+
+fn probe_impl(recipe: &Recipe, accepted: &[UpstreamPin]) -> Result<StageA> {
let mut pins = Vec::new();
let mut unprobed = Vec::new();
for entry in recipe.source_entries.iter().filter(|e| e.is_vcs()) {