pub fn write_test_output(
path: impl AsRef<std::path::Path>,
content: impl AsRef<[u8]>,
) -> std::io::Result<()> {
if std::env::var_os("CI").is_some() {
return Ok(());
}
let _ = std::fs::create_dir("test_outputs");
std::fs::write(path, content)
}
#[allow(dead_code)]
pub fn text_y(svg: &str, content: &str) -> f64 {
let needle = format!(">{content}</text>");
let end = svg
.find(&needle)
.unwrap_or_else(|| panic!("no text {content:?} in SVG"));
let seg = &svg[..end];
let y_start = seg.rfind(r#" y=""#).unwrap() + 4;
let y_end = seg[y_start..].find('"').unwrap() + y_start;
seg[y_start..y_end].parse().unwrap()
}