use std::fs::{DirEntry, read_dir};
use trybuild::TestCases;
fn add_files_recursively(t: &TestCases, entry: DirEntry) {
let ty = entry.file_type().unwrap();
if ty.is_file() {
if entry.path().extension().unwrap() == "rs" {
t.compile_fail(entry.path());
}
} else if ty.is_dir() {
for entry in read_dir(entry.path()).unwrap() {
add_files_recursively(t, entry.unwrap());
}
} else if ty.is_symlink() {
panic!("`{}` is a symlink.", entry.path().to_string_lossy());
} else {
panic!("could not determine the file type of {}", entry.path().to_string_lossy());
}
}
#[test]
fn trybuild() {
let t = TestCases::new();
t.pass("tests/trybuild/workaround.rs");
for entry in read_dir("tests/compile_fail/").unwrap() {
let entry = entry.unwrap();
if entry.path().file_name().unwrap() == "main.rs" {
continue;
}
add_files_recursively(&t, entry);
}
}