use std::path::{Path, PathBuf}; // use fs_err as fs; /* # Why are the tests in src the way insta glob works is it finds the dir the file is in, and then looks at all children, and then checks if they have a match. This means we cant use .. in the glob, as parents arnt generated. A potential solution would be to update insta to use CARGO_MAINIFEST_DIR as the base, and add file!() to the glob, but I'd need to update insta upstream for this */ #[test] fn run_pass() { let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR")); insta::glob!("test/run-pass/**/*.scm", |p| { let p = PathBuf::from( p.canonicalize() .unwrap() .to_str() .unwrap() .replace("\\\\?\\", ""), // Work around IDK on windows ); let cmd = assert_cmd::Command::cargo_bin("handball") .unwrap() .arg(&p) .assert() .success(); let p = p.strip_prefix(manifest_dir).unwrap(); let p = p.strip_prefix("src/test/run-pass").unwrap(); let p = p.to_str().unwrap(); assert_eq!(cmd.get_output().stderr, Vec::::new()); insta::assert_snapshot!( "run-pass", String::from_utf8(cmd.get_output().stdout.clone()).unwrap(), &format!("run-pass {}", p) ); }) }