mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-30 20:58:00 -06:00
test(ui-egui): read tl! literals past test-only imports
This commit is contained in:
@@ -496,7 +496,15 @@ pub fn tl_literals() -> std::collections::BTreeSet<String> {
|
||||
}
|
||||
} 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("");
|
||||
// Code up to the first test item; test-only imports (`#[cfg(test)] use …;`) don't end it.
|
||||
let code = text
|
||||
.match_indices("#[cfg(test)]")
|
||||
.find(|&(at, m)| {
|
||||
let item = text[at + m.len()..].trim_start();
|
||||
let item = ["pub(crate) ", "pub(super) ", "pub "].iter().find_map(|p| item.strip_prefix(p)).unwrap_or(item);
|
||||
!item.starts_with("use ")
|
||||
})
|
||||
.map_or(text.as_str(), |(at, _)| &text[..at]);
|
||||
let mut rest = code;
|
||||
while let Some(at) = rest.find("tl!(\"") {
|
||||
rest = &rest[at + 5..];
|
||||
|
||||
Reference in New Issue
Block a user