pub fn load_runs(
root: &Path,
suite: &str,
) -> (Vec<(String, EconomicsRun)>, Vec<String>)Expand description
Every live run recorded under root for suite, sorted by id, with the files that
could not be read named.
Only *.json files are records. A suite with no directory yet has recorded nothing,
which is not an error; a record that does not parse, carries another schema, or reuses a
run id is named in the second list instead of being dropped.
use majordomus_cli::economics::{load_runs, DIR};
let dir = tempfile::tempdir().unwrap();
let (runs, errors) = load_runs(dir.path(), "pilot");
assert!(runs.is_empty() && errors.is_empty(), "nothing recorded is not an error");
let recorded = dir.path().join(DIR).join("runs/pilot");
std::fs::create_dir_all(&recorded).unwrap();
std::fs::write(recorded.join("notes.txt"), "not a record").unwrap();
std::fs::write(recorded.join("r1.json"), "{").unwrap();
let (runs, errors) = load_runs(dir.path(), "pilot");
assert!(runs.is_empty());
assert_eq!(errors.len(), 1, "the broken record is named, the text file is ignored");
assert!(errors[0].starts_with(&format!("{DIR}/runs/pilot/r1.json: ")));