Another project
0

Configure Feed

Select the types of activity you want to include in your feed.

at main 1.2 kB View raw
1use std::path::{Path, PathBuf}; 2 3use bone_jig::{RunResult, Scenario, ScenarioSource, run_scenario}; 4 5#[must_use] 6pub fn manifest_path(rel: &str) -> PathBuf { 7 PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(rel) 8} 9 10#[must_use] 11pub fn run_library_scenario(name: &str, out_dir: &Path) -> RunResult { 12 let source = ScenarioSource::Path(manifest_path(&format!("scenarios/{name}"))); 13 let scenario = match Scenario::load(&source) { 14 Ok(s) => s, 15 Err(e) => panic!("load {name}: {e}"), 16 }; 17 let mut sink = Vec::new(); 18 match run_scenario(&scenario, out_dir, &mut sink) { 19 Ok(result) => result, 20 Err(e) => panic!("run {name}: {e}"), 21 } 22} 23 24#[must_use] 25pub fn find_artifact(out_dir: &Path, suffix: &str) -> PathBuf { 26 let entries = match std::fs::read_dir(out_dir) { 27 Ok(it) => it, 28 Err(e) => panic!("read {}: {e}", out_dir.display()), 29 }; 30 entries 31 .filter_map(Result::ok) 32 .map(|entry| entry.path()) 33 .find(|path| { 34 path.file_name() 35 .and_then(|n| n.to_str()) 36 .is_some_and(|n| n.ends_with(suffix)) 37 }) 38 .unwrap_or_else(|| panic!("no artifact ending in {suffix} under {}", out_dir.display())) 39}