//! The MoQ file corpus and the V3C corpus (WAI `moqt-conformance/moq-file/` and //! `moqt-conformance/v3c/`; live-recording §8.7, moq-streaming-format §4.5): //! //! cargo run -p joule-moq --example oneway_vectors -- gen writes both (never in CI) //! cargo run -p joule-moq --example oneway_vectors -- verify checks both use std::path::PathBuf; use joule_moq::{file, v3c}; const WAI: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../../../../wai/"); fn main() -> std::process::ExitCode { let files = PathBuf::from(format!("{WAI}moqt-conformance/moq-file")); let v3c_path = format!("{WAI}moqt-conformance/v3c/vectors.json"); match std::env::args().nth(1).as_deref() { Some("gen") => { for (name, bytes) in file::corpus::generate() { let path = files.join(&name); std::fs::create_dir_all(path.parent().expect("a file under the corpus")).expect("the corpus directory"); std::fs::write(&path, bytes).expect("write a corpus file"); } std::fs::create_dir_all(format!("{WAI}moqt-conformance/v3c")).expect("the corpus directory"); std::fs::write(&v3c_path, v3c::corpus::generate()).expect("write vectors.json"); println!("wrote {} and {v3c_path}", files.display()); std::process::ExitCode::SUCCESS } Some("verify") => { let mut fails = file::corpus::verify(&files); match std::fs::read_to_string(&v3c_path).ok().and_then(|s| serde_json::from_str(&s).ok()) { Some(doc) => fails.extend(v3c::corpus::verify(&doc)), None => fails.push("the V3C vectors do not read".into()), } for f in &fails { eprintln!("FAIL {f}"); } println!("{} failures", fails.len()); if fails.is_empty() { std::process::ExitCode::SUCCESS } else { std::process::ExitCode::FAILURE } } _ => { eprintln!("usage: oneway_vectors gen | verify"); std::process::ExitCode::from(2) } } }