#[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_s3_export_required_but_presigned_url_missing() {
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-s3",
"authority":{"secretRefs":[]},
"lifetime":{"ttlSeconds":60},
"export":{
"targets":[
{"name":"artifact-bucket","kind":"s3","bucket":"demo-bucket","keyPrefix":"demo"}
],
"artifacts":[
{"name":"artifact.txt","path":"/tmp/artifact.txt"}
]
}
}
}"#;
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("CELL_OS_REQUIRE_S3_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 S3 export required but presigned URL missing, got {status:?}"
);
}
}