use std::{ fs, path::{Path, PathBuf}, }; pub fn main() { let args: Vec = std::env::args().collect(); if args.len() > 1 { let run = traverse(&args) .and_then(|paths| run_test(&paths)) .expect("Failed to traverse directory"); println!("{:?}", run) } } fn traverse(args: &[String]) -> Result, String> { let mut files: Vec = Vec::new(); for arg in args.iter().skip(1) { let entries = fs::read_dir(arg).map_err(|e| e.to_string())?; for entry in entries { let dir = entry.map_err(|e| e.to_string())?; let f = dir.metadata().map_err(|e| e.to_string())?; if f.is_dir() { files.push(dir.path()); } } } Ok(files) } #[derive(Debug)] struct TestRun { file: String, test_result: bool, duration: u64, } fn run_test(files: &Vec) -> Result, String> { let mut result = Vec::new(); for file in files { let mut inp = file.clone(); let mut outp = file.clone(); inp.push("input"); outp.push("output"); let (test_result, duration) = run_test_case(&inp, &outp); result.push(TestRun { file: inp.as_path().to_str().unwrap().to_string(), test_result, duration, }); } Ok(result) } fn run_test_case(inp: &std::path::PathBuf, outp: &std::path::PathBuf) -> (bool, u64) { (true, 1) }