#[cfg(unix)]
mod unix {
use std::fs::File;
use std::io::Write;
use std::path::{Path, PathBuf};
use std::process::Command;
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 exits_nonzero_when_http_export_required_but_base_url_invalid() {
let dir = tempfile::tempdir().expect("tempdir");
let spec_path = dir.path().join("spec.json");
let json = r#"{"apiVersion":"cellos.io/v1","kind":"ExecutionCell","spec":{"id":"t-req-http","authority":{"secretRefs":[]},"lifetime":{"ttlSeconds":60}}}"#;
let mut f = File::create(&spec_path).expect("create spec");
f.write_all(json.as_bytes()).expect("write spec");
drop(f);
let exe = supervisor_exe();
assert!(
exe.is_file(),
"supervisor binary missing at {}",
exe.display()
);
let status = Command::new(exe)
.env("CELLOS_DEPLOYMENT_PROFILE", "portable")
.env("CELL_OS_USE_NOOP_SINK", "1")
.env(
"CELLOS_EXPORT_HTTP_BASE_URL",
"ftp://example.invalid/not-http-scheme",
)
.env("CELL_OS_REQUIRE_HTTP_EXPORT", "1")
.env("CELLOS_CELL_BACKEND", "stub")
.current_dir(env!("CARGO_MANIFEST_DIR"))
.arg(&spec_path)
.status()
.expect("spawn cellos-supervisor");
assert!(
!status.success(),
"expected failure when HTTP export required but base URL invalid, got {status:?}"
);
}
}