#[cfg(unix)]
mod unix {
use std::io::Write;
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};
fn supervisor_exe() -> PathBuf {
if let Some(p) = std::env::var_os("CARGO_BIN_EXE_cellos_supervisor") {
return PathBuf::from(p);
}
let root = Path::new(env!("CARGO_MANIFEST_DIR"))
.parent()
.and_then(|p| p.parent())
.expect("cellos-supervisor crate under workspace root");
let profile = std::env::var("PROFILE").unwrap_or_else(|_| "debug".into());
root.join("target").join(profile).join("cellos-supervisor")
}
#[test]
fn supervisor_reads_spec_from_stdin_dash() {
let exe = supervisor_exe();
assert!(
exe.is_file(),
"supervisor binary missing at {} — run `cargo build -p cellos-supervisor`",
exe.display()
);
let json = r#"{"apiVersion":"cellos.io/v1","kind":"ExecutionCell","spec":{"id":"t-stdin","authority":{"secretRefs":[]},"lifetime":{"ttlSeconds":60},"run":{
"secretDelivery": "env","argv":["true"]}}}"#;
let mut child = Command::new(exe)
.env("CELLOS_DEPLOYMENT_PROFILE", "portable")
.env("CELL_OS_USE_NOOP_SINK", "1")
.env("CELLOS_CELL_BACKEND", "stub")
.current_dir(env!("CARGO_MANIFEST_DIR"))
.arg("-")
.stdin(Stdio::piped())
.spawn()
.expect("spawn cellos-supervisor");
{
let stdin = child.stdin.as_mut().expect("stdin pipe");
stdin
.write_all(json.as_bytes())
.expect("write spec to stdin");
}
let status = child.wait().expect("wait cellos-supervisor");
assert!(status.success(), "supervisor failed: {status:?}");
}
}