From cf5fe9afbd2c914bf71c44726b4d47d175275890 Mon Sep 17 00:00:00 2001 From: MashPlant <740678788@qq.com> Date: Mon, 30 Sep 2019 12:33:39 +0800 Subject: [PATCH] simplify test path --- driver/Cargo.toml | 1 - driver/src/test.rs | 2 +- driver/src/test_util.rs | 12 ++++++------ 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/driver/Cargo.toml b/driver/Cargo.toml index 4469b02..3cf0d21 100644 --- a/driver/Cargo.toml +++ b/driver/Cargo.toml @@ -13,7 +13,6 @@ tac = { path = "../tac" } tacgen = { path = "../tacgen" } tacopt = { path = "../tacopt" } codegen = { path = "../codegen" } -duct = "0.12.0" typed-arena = "1.4.1" tacvm = { git = "https://github.com/MashPlant/tacvm" } colored = "1.8" diff --git a/driver/src/test.rs b/driver/src/test.rs index 0f2d8c7..4c0e570 100644 --- a/driver/src/test.rs +++ b/driver/src/test.rs @@ -1,7 +1,7 @@ use driver::*; fn main() { - for result in test_all("testcase", "pa5", Pa::Pa5).unwrap() { + for result in test_all("testcase/S1", Pa::Pa1a).unwrap() { println!("{:?}", result); } } diff --git a/driver/src/test_util.rs b/driver/src/test_util.rs index f2702f1..7bc3793 100644 --- a/driver/src/test_util.rs +++ b/driver/src/test_util.rs @@ -26,24 +26,24 @@ const SPIM_INFO_LINE: usize = 1; // `folder` should be the path of folder containing `pa_path` and other tools // `pa_path` should be relevant to `folder`, i.e., `folder`/`pa_path` is the real path to pa folder -pub fn test_all(folder: impl AsRef, pa_path: impl AsRef, pa: Pa) -> io::Result> { +pub fn test_all(path: impl AsRef, pa: Pa) -> io::Result> { // make color work properly on windows(powershell) // if it still doesn't work, or you simply dislike the color, add `colored::control::set_override(false);` before calling `test_all` #[cfg(target_os = "windows")] let _ = control::set_virtual_terminal(true); - let folder = folder.as_ref().join(pa_path); - let ans = folder.join("result"); - let out = folder.join("out"); + let path = path.as_ref(); + let ans = path.join("result"); + let out = path.join("out"); if !out.exists() { fs::create_dir_all(&out)?; } - let mut files = fs::read_dir(&folder)?.filter_map(|f| { + let mut files = fs::read_dir(path)?.filter_map(|f| { let path = f.ok()?.path(); let name = path.file_name()?.to_str()?; // in normal case none of the above 3 ? will fail if path.is_file() && name.ends_with(".decaf") { Some(name.to_owned()) } else { None } }).collect::>(); files.sort_unstable(); // the order of fs::read_dir may be strange, sort them for better debugging let ret = files.iter().map(|f| { - test_one_caught(folder.join(f), out.join(f).with_extension("result"), ans.join(f).with_extension("result"), pa) + test_one_caught(path.join(f), out.join(f).with_extension("result"), ans.join(f).with_extension("result"), pa) }).collect(); Ok(ret) }