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/config.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/config.rs')
| -rw-r--r-- | src/config.rs | 32 |
1 files changed, 8 insertions, 24 deletions
diff --git a/src/config.rs b/src/config.rs index 1b9f26a..7f406a0 100644 --- a/src/config.rs +++ b/src/config.rs @@ -2,8 +2,7 @@ use std::path::{Path, PathBuf}; use serde::{Deserialize, Serialize}; -/// The image a build runs in when the config does not say. Only this module -/// resolves it, so it is not part of the crate's interface. +/// The image a build runs in when the config does not say. const DEFAULT_SANDBOX_IMAGE: &str = "aur-build-sandbox:latest"; #[derive(Clone, Default, Serialize, Deserialize)] @@ -91,9 +90,6 @@ impl Sandbox { } /// Validation consults it; the fixture-bound tests that assert it are the only outside readers. - /// - /// 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 shared_workspace(&self) -> bool { Self::shared_workspace_impl(self) @@ -112,9 +108,8 @@ impl Sandbox { } } - /// The accepted values, so a test can assert that an unknown kind names - /// the whole valid set rather than one example of it. Serde builds the - /// rejection message itself, so nothing in production reads this list. + /// The accepted values. Serde builds the rejection message itself, so + /// nothing in production reads this list. #[cfg(test)] const KINDS: [&'static str; 3] = ["loopback", "remote", "agent-sandbox"]; } @@ -145,10 +140,8 @@ pub struct Config { pub dispatch_tick_secs: u64, } -/// Test-tier only, and already half-gated: the `hooks` field that holds one and -/// the `Default` line that fills it are both behind `test-support`, so without -/// the gate below this type compiles into a release binary that can never -/// construct, read, or deserialize it. +/// Test-tier only: the `hooks` field that holds one is gated, so an ungated +/// type here would compile into a release binary that can never construct it. #[cfg(feature = "test-support")] #[derive(Debug, Clone, Default, Serialize, Deserialize)] #[serde(default)] @@ -274,8 +267,7 @@ impl Config { Ok(()) } - // Everything this assembles comes from the `test-support`-gated `hooks` - // field, so in a release build the argument and the vector are both unused. + // Assembled only from the `test-support`-gated `hooks` field. #[cfg_attr(not(feature = "test-support"), allow(unused_variables))] pub fn child_env_pairs(&self) -> Vec<(String, String)> { #[cfg_attr(not(feature = "test-support"), allow(unused_mut))] @@ -358,9 +350,6 @@ impl Config { self.staging_dir().join(build_id) } /// The content-addressed store layout is this module's own business; a test pins where a blob lands. - /// - /// 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 store_dir(&self) -> PathBuf { Self::store_dir_impl(self) @@ -445,10 +434,8 @@ fn slug(url: &str) -> String { mod tests { use super::*; - // `Config::load` takes a directory, so parsing a config means having a file - // on disk somewhere. The tempdir below is plumbing for that signature, not - // something these tests are about: none of them touches the database, the - // fixture corpus, or a subprocess. + // `Config::load` takes a directory, so the tempdir is plumbing for the + // signature, not something these parsing tests are about. fn load_sandbox(sandbox: &str) -> Result<Config, String> { let tmp = tempfile::tempdir().unwrap(); std::fs::write(tmp.path().join("config.json"), format!("{{\n \"sandbox\": {sandbox}\n}}\n")).unwrap(); @@ -461,9 +448,6 @@ mod tests { Config::load(tmp.path()).map_err(|e| e.to_string()) } - // Moved verbatim from tests/config.rs: these eleven exercise parsing, - // validation and Debug redaction of the config itself. - #[test] fn each_sandbox_kind_parses_with_its_required_fields() { match load_sandbox(r#"{"kind":"loopback"}"#).unwrap().sandbox { |
