1pub mod cc_switch;
4pub mod cli;
5pub mod config;
6pub mod discovery;
7pub mod history;
8pub mod sync;
9pub mod web;
10
11#[cfg(test)]
12mod architecture_tests {
13 use std::{fs, path::Path};
14 use walkdir::WalkDir;
15
16 #[test]
17 fn modules_use_named_files_instead_of_mod_rs() {
18 let source = Path::new(env!("CARGO_MANIFEST_DIR")).join("src");
19
20 let legacy_modules = WalkDir::new(&source)
21 .into_iter()
22 .filter_map(Result::ok)
23 .filter(|entry| entry.file_type().is_file() && entry.file_name() == "mod.rs")
24 .map(|entry| entry.path().display().to_string())
25 .collect::<Vec<_>>();
26 assert!(
27 legacy_modules.is_empty(),
28 "禁止使用 mod.rs:{}",
29 legacy_modules.join(", ")
30 );
31
32 for entry in fs::read_dir(&source).expect("read src") {
33 let path = entry.expect("read src entry").path();
34 if !path.is_dir() {
35 continue;
36 }
37 let module = path.file_name().expect("module directory name");
38 let entry_file = source.join(module).with_extension("rs");
39 assert!(
40 entry_file.is_file(),
41 "模块目录 {} 缺少同名入口文件 {}",
42 path.display(),
43 entry_file.display()
44 );
45 }
46 }
47}