summaryrefslogtreecommitdiffstats
path: root/src/db
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/db
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/db')
-rw-r--r--src/db/migrations.rs13
-rw-r--r--src/db/mod.rs4
2 files changed, 16 insertions, 1 deletions
diff --git a/src/db/migrations.rs b/src/db/migrations.rs
index cb01765..015610a 100644
--- a/src/db/migrations.rs
+++ b/src/db/migrations.rs
@@ -323,7 +323,12 @@ CREATE TABLE IF NOT EXISTS gc_run (
);
"#;
-pub static MIGRATIONS: &[Migration] = &[
+/// The migration list, in version order.
+///
+/// `db::migrate` walks it; nothing outside `db` asks for the list itself
+/// except a test that asserts it is ordered and complete. The table lives
+/// once, in `MIGRATIONS_ALL`, so the two aliases below cannot drift apart.
+static MIGRATIONS_ALL: &[Migration] = &[
Migration { version: 1, name: "core", sql: M_0001_CORE },
Migration { version: 2, name: "build", sql: M_0002_BUILD },
Migration { version: 3, name: "notices", sql: M_0003_NOTICES },
@@ -334,6 +339,12 @@ pub static MIGRATIONS: &[Migration] = &[
Migration { version: 8, name: "retention", sql: M_0008_RETENTION },
];
+#[cfg(feature = "test-support")]
+pub static MIGRATIONS: &[Migration] = MIGRATIONS_ALL;
+
+#[cfg(not(feature = "test-support"))]
+pub(crate) static MIGRATIONS: &[Migration] = MIGRATIONS_ALL;
+
pub(crate) const DEFAULT_SETTINGS: &[(&str, &str)] = &[
("max_concurrent_builds", "1"),
("build_timeout", "5400"),
diff --git a/src/db/mod.rs b/src/db/mod.rs
index 992a2b6..1266d9e 100644
--- a/src/db/mod.rs
+++ b/src/db/mod.rs
@@ -24,6 +24,10 @@ mod staleness;
mod subscriptions;
mod world;
+/// The alias is only ever used from outside `db`, and only by the test tier;
+/// `db::migrate` walks `migrations::MIGRATIONS` by its own path, so there is
+/// no crate-internal alias to keep in a production build.
+#[cfg(feature = "test-support")]
pub use migrations::MIGRATIONS;
pub(crate) use model::StateEnum;
/// Its only caller is the test-tier `world_members`, so it is gated with it.