From 8bb76cb266a2fef5d5fe43c0f9643101f59112aa Mon Sep 17 00:00:00 2001 From: aur-build Date: Wed, 18 Nov 2026 17:16:23 +0000 Subject: config: the test hooks are a gated submodule, not the production surface MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Seven fields sat on `Config` next to `signing_key_id` and `bind`: a PATH override, three shim protocol variables, a fault-injection point in the middle of `publish()`, and two more shims could obey. m-9's complaint was not that they exist โ€” the shims are how I4, I5 and I9 are tested for real, and a mock would have asserted the mock's own behaviour โ€” but that nothing said which of these was production and which was scaffolding, and the publish path carried a test branch on every real publish. They are one `TestHooks` submodule now, documented as what it is, and the whole submodule is `#[cfg(feature = "test-support")]` โ€” the same feature that already gates the shims and the raw SQL escape hatch, and which only this crate's own dev-dependency turns on. A production build has no `hooks` field, no shim protocol in `child_env`, and no fault-injection branch in `publish()`; the serialized config skips the section entirely when nothing is hooked, so a real `config.json` never mentions any of it. `TestHooks::is_empty()` names the state a real process runs in, and three tests hold the line: the hook fields may be declared exactly once and only inside `TestHooks`, every `publish_fault` read in `publish.rs` must sit behind the feature gate, and a default config serializes without a trace of hooks. --- tests/common/mod.rs | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'tests/common/mod.rs') diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 58c6dae..426f44d 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -5,7 +5,7 @@ use std::path::{Path, PathBuf}; -use aur_build::config::Config; +use aur_build::config::{Config, TestHooks}; use aur_build::db::{self, Db}; pub struct Env { @@ -127,14 +127,14 @@ impl Env { /// Make the next publish abort at a named point (I4 / I5 tests). pub fn set_publish_fault(&mut self, at: &str) { - self.cfg.publish_fault = Some(at.to_string()); + self.cfg.hooks.publish_fault = Some(at.to_string()); } pub fn clear_publish_fault(&mut self) { - self.cfg.publish_fault = None; + self.cfg.hooks.publish_fault = None; } /// Make the named shim fail (the "build failed" path, ยง8.4). pub fn set_shim_fail(&mut self, tool: &str) { - self.cfg.shim_fail = Some(tool.to_string()); + self.cfg.hooks.shim_fail = Some(tool.to_string()); } pub fn query_i64(&self, sql: &str, params: &[P]) -> Option { @@ -236,12 +236,15 @@ pub fn env_with_fixture(name: &str) -> (Env, Fixture) { let cfg = Config { root: tmp.path().to_path_buf(), signing_key_id: "TESTKEY".into(), - path_prepend: Some(shim_dir()), - shim_manifest: Some(fx.manifest.clone()), - shim_dir: Some(tmp.path().join("shimlog")), + hooks: TestHooks { + path_prepend: Some(shim_dir()), + shim_manifest: Some(fx.manifest.clone()), + shim_dir: Some(tmp.path().join("shimlog")), + ..TestHooks::default() + }, ..Config::default() }; - std::fs::create_dir_all(cfg.shim_dir.as_ref().unwrap()).unwrap(); + std::fs::create_dir_all(cfg.hooks.shim_dir.as_ref().unwrap()).unwrap(); cfg.ensure_dirs().unwrap(); let env = Env::with_cfg(tmp, cfg); env.subscribe(name); @@ -258,12 +261,15 @@ pub fn env_with_two_fixtures(a: &str, b: &str) -> (Env, Fixture, Fixture) { let cfg = Config { root: tmp.path().to_path_buf(), signing_key_id: "TESTKEY".into(), - path_prepend: Some(shim_dir()), - shim_manifest: Some(fb.manifest.clone()), - shim_dir: Some(tmp.path().join("shimlog")), + hooks: TestHooks { + path_prepend: Some(shim_dir()), + shim_manifest: Some(fb.manifest.clone()), + shim_dir: Some(tmp.path().join("shimlog")), + ..TestHooks::default() + }, ..Config::default() }; - std::fs::create_dir_all(cfg.shim_dir.as_ref().unwrap()).unwrap(); + std::fs::create_dir_all(cfg.hooks.shim_dir.as_ref().unwrap()).unwrap(); cfg.ensure_dirs().unwrap(); let env = Env::with_cfg(tmp, cfg); env.subscribe(a); -- cgit v1.2.3