use super::*;
use crate::test_support::with_lernie_home;
use std::path::{Path, PathBuf};
use std::sync::atomic::AtomicBool;
mod agent_id;
mod cwd;
mod dispatching;
mod naming;
mod pins;
mod retargeting;
mod surface;
mod verbs;
mod verbs_more;
fn noop_editor(_: &Path) -> std::io::Result<()> {
Ok(())
}
fn writing_editor(dir: &Path) -> std::io::Result<()> {
std::fs::write(dir.join("providers.yaml"), "roles: {}\n")
}
fn assert_prefixed(err: Error, prefix: &str) {
let s = err.to_string();
assert!(s.starts_with(&format!("lernie {prefix}: ")), "{s}");
}
#[rustfmt::skip]
fn with_fx<R>(
driver_target: &str,
stdin: &[u8],
editor: &dyn Fn(&Path) -> std::io::Result<()>,
f: impl FnOnce(&mut Fx) -> R,
) -> (R, Vec<u8>, Vec<u8>) {
let mut stdin_ref = stdin;
let mut stdout: Vec<u8> = Vec::new();
let mut stderr: Vec<u8> = Vec::new();
let stop = AtomicBool::new(false);
let mut fx = Fx { driver_target: PathBuf::from(driver_target), adapter_target: None, editor, tool_stdin: &mut stdin_ref, tool_stdout: &mut stdout, tool_stderr: &mut stderr, stop: &stop, tool_injection: None };
let r = f(&mut fx);
drop(fx);
(r, stdout, stderr)
}