diff --git a/src/test/mod.rs b/src/test/mod.rs index 6478223..c1bffd7 100644 --- a/src/test/mod.rs +++ b/src/test/mod.rs @@ -15,6 +15,9 @@ const TEST_FILE: &str = "/home/dide/project/Digital-Test/MipsDesign/src/MyCpu.v" #[allow(unused)] const INCOMPLETE_EXAMPLE: &str = "/home/dide/project/Digital-Test/Digital-IDE-test/user/src/incomplete-example"; +#[allow(unused)] +const DIGTIAL_IDE_FACTORY: &str = "/home/dide/project/Digital-Test/Digital-IDE-test/user/factory"; + #[allow(unused)] const TESTFILES_TEMP_DIR: &str = "/home/dide/project/Digital-Test/Digital-IDE-temp"; @@ -103,6 +106,20 @@ mod test_fast { } } + #[test] + fn test_factory() { + // 判断路径是否存在且为文件夹 + let path = Path::new(DIGTIAL_IDE_FACTORY); + if path.exists() && path.is_dir() { + // 递归遍历文件夹 + if let Err(e) = traverse_directory(path) { + eprintln!("Error: {}", e); + } + } else { + eprintln!("Path does not exist or is not a directory"); + } + } + #[test] fn test_mips_design() { // 判断路径是否存在且为文件夹 @@ -184,7 +201,7 @@ mod test_svparse { use tower_lsp::lsp_types::{Position, Range, Url}; use crate::sources::recovery_sv_parse_with_retry; - use super::{INCOMPLETE_EXAMPLE, TEST_FILE}; + use super::{INCOMPLETE_EXAMPLE, TEST_FILE, DIGTIAL_IDE_FACTORY}; #[test] /// 测试单独的文件 @@ -228,6 +245,19 @@ mod test_svparse { eprintln!("Path does not exist or is not a directory"); } } + + #[test] + fn test_factory() { + let path = Path::new(DIGTIAL_IDE_FACTORY); + if path.exists() && path.is_dir() { + // 递归遍历文件夹 + if let Err(e) = traverse_directory(path) { + eprintln!("Error: {}", e); + } + } else { + eprintln!("Path does not exist or is not a directory"); + } + } fn traverse_directory(dir: &Path) -> Result<(), Box> { if dir.is_dir() { @@ -367,6 +397,19 @@ mod test_scope_tree { } } + #[test] + fn test_factory() { + let path = Path::new(DIGTIAL_IDE_FACTORY); + if path.exists() && path.is_dir() { + // 递归遍历文件夹 + if let Err(e) = traverse_directory(path) { + eprintln!("Error: {}", e); + } + } else { + eprintln!("Path does not exist or is not a directory"); + } + } + fn traverse_directory(dir: &Path) -> Result<(), Box> { if dir.is_dir() { for entry in fs::read_dir(dir)? {