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/<topic>.rs are not read as interface code.
This commit is contained in:
aiongg
2026-10-26 18:05:40 +00:00
parent e2a8280134
commit 777a764a0e
3 changed files with 24 additions and 13 deletions
+18 -11
View File
@@ -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());
}
}
}
}
+3 -1
View File
@@ -491,7 +491,9 @@ pub fn tl_literals() -> std::collections::BTreeSet<String> {
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("");
+3 -1
View File
@@ -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())));