diff options
Diffstat (limited to 'src/config.rs')
| -rw-r--r-- | src/config.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/config.rs b/src/config.rs index 44b110c..05f9a74 100644 --- a/src/config.rs +++ b/src/config.rs @@ -46,6 +46,10 @@ pub struct Config { /// Directory prepended to PATH for child processes. The test harness puts /// the toolchain shims here (§16a). pub path_prepend: Option<PathBuf>, + /// Fixture manifest the shims should obey, exported as `AUR_SHIM_MANIFEST`. + pub shim_manifest: Option<PathBuf>, + /// Where shims record their invocations, exported as `AUR_SHIM_DIR`. + pub shim_dir: Option<PathBuf>, } impl Default for Config { @@ -67,6 +71,8 @@ impl Default for Config { gpg_bin: "gpg".into(), build_user: String::new(), path_prepend: None, + shim_manifest: None, + shim_dir: None, } } } @@ -96,6 +102,21 @@ impl Config { Ok(()) } + /// Environment for a child process: PATH with the shims in front, plus the + /// shim protocol variables (§16a). + pub fn child_env(&self, cmd: &mut std::process::Command) { + if let Some(dir) = &self.path_prepend { + let path = std::env::var("PATH").unwrap_or_default(); + cmd.env("PATH", format!("{}:{path}", dir.display())); + } + if let Some(m) = &self.shim_manifest { + cmd.env("AUR_SHIM_MANIFEST", m); + } + if let Some(d) = &self.shim_dir { + cmd.env("AUR_SHIM_DIR", d); + } + } + /// Create the directory tree the server needs. Idempotent. pub fn ensure_dirs(&self) -> anyhow::Result<()> { for d in [ |
