interplane.Get Omega
Read in your language

spark-rsi-mv

Native Rust recursive self-improvement engine with paired bootstrap evaluation and cryptographic ledger

Brought by drakestapleton

branch main Branches Tags History

spark-rsi-mv / tests / canary_fixture / mod.rs

39 lines · 1438 bytes Raw Blame History
1//! Builds the canary fixture crate once per test binary and hands back its executable.
2
3use std::path::{Path, PathBuf};
4use std::process::Command;
5use std::sync::OnceLock;
6
7pub fn fixture_dir() -> PathBuf {
8 Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures/canary-target")
9}
10
11/// `cargo build --release --offline --locked --manifest-path fixtures/canary-target/Cargo.toml`,
12/// run once, returning `fixtures/canary-target/target/release/canary-target`.
13pub fn fixture_executable() -> &'static Path {
14 static BUILT: OnceLock<PathBuf> = OnceLock::new();
15 BUILT.get_or_init(|| {
16 let manifest = fixture_dir().join("Cargo.toml");
17 let cargo = std::env::var("CARGO").unwrap_or_else(|_| "cargo".to_string());
18 let out = Command::new(cargo)
19 .args([
20 "build",
21 "--release",
22 "--offline",
23 "--locked",
24 "--manifest-path",
25 ])
26 .arg(&manifest)
27 .env_remove("CARGO_TARGET_DIR")
28 .output()
29 .expect("cannot run cargo to build the canary fixture");
30 assert!(
31 out.status.success(),
32 "canary fixture build failed:\n{}",
33 String::from_utf8_lossy(&out.stderr)
34 );
35 let exe = fixture_dir().join("target/release/canary-target");
36 assert!(exe.is_file(), "fixture executable missing at {:?}", exe);
37 exe
38 })
39}