const EXPAND_DIR: &'static str = "tests/expand";
const TESTING_DIR: &'static str = "testing";
#[test]
pub fn pass()
{
let _ = std::fs::remove_dir_all(EXPAND_DIR.to_owned() + "/" + TESTING_DIR);
std::fs::create_dir_all(EXPAND_DIR.to_owned() + "/" + TESTING_DIR).unwrap();
copy_from("from");
if std::path::Path::new(&(EXPAND_DIR.to_owned() + "/expected")).exists()
{
copy_from("expected");
}
copy_for_both_syntaxes();
macrotest::expand_without_refresh(EXPAND_DIR.to_owned() + "/" + TESTING_DIR + "/*.rs");
}
fn copy_from(source_dir: &str)
{
let files = std::fs::read_dir(EXPAND_DIR.to_owned() + "/" + source_dir).unwrap();
for file in files
{
if let Ok(file) = file
{
let file_name = file.file_name();
let file_path = file.path();
let mut destination = file_path.clone();
destination.pop();
destination.pop();
destination.push(TESTING_DIR);
destination.push(file_name);
std::fs::copy(&file_path, &destination).unwrap();
}
else
{
panic!("Error copying files from: ".to_owned() + source_dir)
}
}
}
fn copy_for_both_syntaxes()
{
let expected_files = std::fs::read_dir(EXPAND_DIR.to_owned() + "/expected_both").unwrap();
for file in expected_files
{
if let Ok(file) = file
{
let file_name = file.file_name();
let file_path = file.path();
let mut destination_short = file_path.clone();
destination_short.pop();
destination_short.pop();
destination_short.push(TESTING_DIR);
let mut destination_verbose = destination_short.clone();
destination_short.push("short_".to_owned() + file_name.to_str().unwrap());
destination_verbose.push("verbose_".to_owned() + file_name.to_str().unwrap());
std::fs::copy(&file_path, destination_short).unwrap();
std::fs::copy(&file_path, destination_verbose).unwrap();
}
else
{
panic!("Error copying expected_both files.")
}
}
}