From 777a764a0e01918152c36ce58ed17dc93ad7ebed Mon Sep 17 00:00:00 2001 From: aiongg Date: Mon, 26 Oct 2026 18:05:40 +0000 Subject: [PATCH] test: scan source directories recursively The EPS error-meaning test walks src/import and its subdirectories. The picks and tl! literal scans skip directories named tests, as the undo and message scans already do, so test modules moved to foo/tests.rs or tests/.rs are not read as interface code. --- crates/eps/src/import/tests_generators.rs | 29 ++++++++++++++--------- crates/ui-egui/src/i18n/tests.rs | 4 +++- crates/ui-egui/src/tests_picks.rs | 4 +++- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/crates/eps/src/import/tests_generators.rs b/crates/eps/src/import/tests_generators.rs index 892bcf417..2fe6ba324 100644 --- a/crates/eps/src/import/tests_generators.rs +++ b/crates/eps/src/import/tests_generators.rs @@ -768,17 +768,24 @@ fn errors_say_what_the_postscript_error_means() { fn every_postscript_error_the_reader_raises_has_a_meaning() { let dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("src").join("import"); let mut raised = std::collections::BTreeSet::new(); - for entry in std::fs::read_dir(&dir).unwrap() { - let path = entry.unwrap().path(); - let name = path.file_name().and_then(|n| n.to_str()).unwrap_or_default(); - if !name.ends_with(".rs") || name.starts_with("tests") { - continue; - } - let text = std::fs::read_to_string(&path).unwrap(); - for marker in ["Ps(\"", "ps_err(\""] { - for (at, _) in text.match_indices(marker) { - let rest = &text[at + marker.len()..]; - raised.insert(rest[..rest.find('"').unwrap()].to_string()); + let mut stack = vec![dir]; + while let Some(d) = stack.pop() { + for entry in std::fs::read_dir(&d).unwrap() { + let path = entry.unwrap().path(); + let name = path.file_name().and_then(|n| n.to_str()).unwrap_or_default(); + if path.is_dir() { + stack.push(path); + continue; + } + if !name.ends_with(".rs") || name.starts_with("tests") { + continue; + } + let text = std::fs::read_to_string(&path).unwrap(); + for marker in ["Ps(\"", "ps_err(\""] { + for (at, _) in text.match_indices(marker) { + let rest = &text[at + marker.len()..]; + raised.insert(rest[..rest.find('"').unwrap()].to_string()); + } } } } diff --git a/crates/ui-egui/src/i18n/tests.rs b/crates/ui-egui/src/i18n/tests.rs index d383eaa01..22ade9b79 100644 --- a/crates/ui-egui/src/i18n/tests.rs +++ b/crates/ui-egui/src/i18n/tests.rs @@ -491,7 +491,9 @@ pub fn tl_literals() -> std::collections::BTreeSet { let path = entry.path(); let name = path.file_name().and_then(|n| n.to_str()).unwrap_or(""); if path.is_dir() { - stack.push(path); + if name != "tests" { + stack.push(path); + } } else if name.ends_with(".rs") && name != "lib.rs" && !name.starts_with("tests") { let text = std::fs::read_to_string(&path).unwrap_or_default(); let code = text.split("#[cfg(test)]").next().unwrap_or(""); diff --git a/crates/ui-egui/src/tests_picks.rs b/crates/ui-egui/src/tests_picks.rs index 686fddd18..609f38bd5 100644 --- a/crates/ui-egui/src/tests_picks.rs +++ b/crates/ui-egui/src/tests_picks.rs @@ -991,7 +991,9 @@ fn only_picks_shows_the_hosts_dialogs() { let path = entry.path(); let name = path.file_name().and_then(|n| n.to_str()).unwrap_or("").to_string(); if path.is_dir() { - stack.push(path); + if name != "tests" { + stack.push(path); + } } else if name.ends_with(".rs") && !name.starts_with("tests") && name != "picks.rs" { let key = path.strip_prefix(&dir).unwrap().to_string_lossy().replace('\\', "/"); scanned.insert(key, without_tests(&code_only(&std::fs::read_to_string(&path).unwrap())));