From cae9e1ebc1d9812a951e640dbe455e437e69f539 Mon Sep 17 00:00:00 2001 From: Pavlo Ratushnyi Date: Fri, 6 Nov 2026 14:45:45 +0100 Subject: [PATCH] STRA-338: the bring-up print gate treats the children of test-only files as test-only (split modules) --- .../tests/bringup_prints_gated.rs | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/crates/engine-qwen35-cuda/tests/bringup_prints_gated.rs b/crates/engine-qwen35-cuda/tests/bringup_prints_gated.rs index ad84fba6..c7ee9f04 100644 --- a/crates/engine-qwen35-cuda/tests/bringup_prints_gated.rs +++ b/crates/engine-qwen35-cuda/tests/bringup_prints_gated.rs @@ -90,9 +90,37 @@ fn test_only(files: &[PathBuf]) -> Vec { } } } + descend(&mut gated); gated } +/// The children of a test-only file are test-only too: every `mod name;` it declares (split modules, `#[path]` ones included). +fn descend(gated: &mut Vec) { + let mut next = 0; + while next < gated.len() { + let file = gated[next].clone(); + next += 1; + let Ok(text) = fs::read_to_string(&file) else { continue }; + let Some(dir) = file.parent() else { continue }; + let own = file.file_stem().map(|stem| dir.join(stem)).unwrap_or_default(); + let lines: Vec<&str> = text.lines().collect(); + for (index, line) in lines.iter().enumerate() { + let trimmed = line.trim_start(); + let declared = trimmed.strip_prefix("pub(crate) mod ").or_else(|| trimmed.strip_prefix("pub(super) mod ")).or_else(|| trimmed.strip_prefix("pub mod ")).or_else(|| trimmed.strip_prefix("mod ")); + let Some(name) = declared.and_then(|rest| rest.strip_suffix(';')) else { continue }; + let mut candidates = vec![own.join(format!("{name}.rs")), own.join(name).join("mod.rs"), dir.join(format!("{name}.rs"))]; + if let Some(path) = lines[..index].iter().rev().take(3).find_map(|l| l.trim().strip_prefix("#[path = \"").and_then(|r| r.split('"').next())) { + candidates.push(dir.join(path)); + } + for candidate in candidates { + if candidate.is_file() && !gated.contains(&candidate) { + gated.push(candidate); + } + } + } + } +} + /// The first string literal of the macro call starting at `at` in `lines`, or `None`. fn first_literal(lines: &[&str], at: usize, column: usize) -> Option { let mut text = String::from(&lines[at][column..]);