pub fn run(
opts: &RunOptions,
decl: &Declarations,
log: &(dyn Fn(String) + Sync),
) -> Result<(Vec<PathBuf>, Vec<String>), String>Expand description
Run a live suite: every job not yet recorded, parallel at a time, control and
treatment of one task and repetition side by side so that both meet the provider under
the same conditions. Returns the records written and the jobs that failed to produce
one. Refuses, before any workspace exists, force (a recorded run is never written
over), an unknown suite, a suite that is not live, a task the suite names but nobody
declared, and a work directory — or a system temporary directory — inside the
repository.
use std::{sync::Mutex, time::Duration};
use majordomus_cli::economics::runner::{run, RunOptions};
let (repo, work) = (tempfile::tempdir().unwrap(), tempfile::tempdir().unwrap());
let mut opts = RunOptions {
root: repo.path().into(), suite: "pilot".into(), tasks: vec![], repetitions: vec![],
work_dir: work.path().into(), harness: "claude".into(), majordomus: "majordomus".into(),
parallel: 1, force: false, dry_run: false, session_timeout: Duration::from_secs(600),
};
// `pilot` is a live suite that names no task yet: nothing runs, nothing is written
let log = Mutex::new(Vec::new());
let (written, failed) = run(&opts, &decl, &|line| log.lock().unwrap().push(line)).unwrap();
assert!(written.is_empty() && failed.is_empty());
assert_eq!(log.into_inner().unwrap(), ["pilot: 0 run(s) to do, 1 at a time"]);
// transcripts never enter the repository, and the refusal leaves nothing behind
opts.work_dir = repo.path().join("economics-work");
assert!(run(&opts, &decl, &|_| {}).unwrap_err().contains("outside the repository"));
assert!(!opts.work_dir.exists());