use super::*;
const ENV_BODY: &str = "#!/bin/sh\nprintf '%s|%s\\n' \"$YOG_WALL\" \"$YOG_NAME\"\nexit 0\n";
fn fire(ws: &Path) -> crate::fork::Fire {
crate::fork::Fire::at(
ws,
"c-parent",
&crate::fork::Attempt {
from: "config/default".to_owned(),
role: "builder".to_owned(),
skills: vec![],
},
"do the thing",
Path::new("/no/yog-data"),
)
}
#[test]
fn every_workspace_bound_verb_spawns_inside_the_sphere() {
let w = World::new("litany", ENV_BODY);
let env = Env::from_pairs([("XDG_DATA_HOME", w.state.path().display().to_string())]);
let leaf = crate::naming::leaf(&w.cwd);
let expected = format!(
"{}|{leaf}\n",
crate::world::wall::root_of(&env, &w.cwd).display()
);
assert!(!leaf.is_empty(), "the fixture workspace has a §3.1 name");
let b = w.bound();
let seen = [
message(&b, w.state.path(), "TS", "a-1", "hi").unwrap(),
stop(&b, w.state.path(), "TS", "a-1", false).unwrap(),
scan(&b, w.state.path(), "TS").unwrap(),
fork(&b, w.state.path(), "TS", &fire(&w.cwd)).unwrap(),
];
for out in &seen {
assert_eq!(out.stdout, expected, "an unwalled workspace-bound spawn");
}
}
#[test]
fn binding_extends_the_standing_world_env() {
let w = World::new(
"litany",
"#!/bin/sh\nprintf '%s\\n' \"$LITANY_HOME\"\nexit 0\n",
);
let world = Env::from_pairs([("XDG_DATA_HOME", w.state.path().display().to_string())]);
let nested = w.cli.clone().with_env(vec![(
"LITANY_HOME".to_owned(),
"/nested/litany".to_owned(),
)]);
let bound = Bound::at(&nested, &world, &w.cwd);
assert_eq!(
scan(&bound, w.state.path(), "TS").unwrap().stdout,
"/nested/litany\n"
);
assert_eq!(bound.workspace(), w.cwd.as_path());
assert_eq!(bound.workspace_arg(), w.cwd.display().to_string());
assert_ne!(bound.cli(), &nested, "binding is not a no-op");
}