Simplify some test code (#6669)

This commit is contained in:
Adam Chalmers
2025-05-02 16:39:20 -05:00
committed by GitHub
parent c327c73087
commit b71eb4fb89

View File

@ -1,9 +1,4 @@
use std::{ use std::{collections::HashMap, fs, path::Path};
collections::HashMap,
fs::{self, File},
io::Read as _,
path::Path,
};
use anyhow::Result; use anyhow::Result;
use base64::Engine; use base64::Engine;
@ -672,9 +667,7 @@ async fn test_code_in_topics() {
let mut join_set = JoinSet::new(); let mut join_set = JoinSet::new();
for name in LANG_TOPICS { for name in LANG_TOPICS {
let filename = format!("../../docs/kcl/{}.md", name.to_lowercase().replace(' ', "-")); let filename = format!("../../docs/kcl/{}.md", name.to_lowercase().replace(' ', "-"));
let mut file = File::open(&filename).unwrap(); let text = std::fs::read_to_string(&filename).unwrap();
let mut text = String::new();
file.read_to_string(&mut text).unwrap();
for (i, (eg, attr)) in find_examples(&text, &filename).into_iter().enumerate() { for (i, (eg, attr)) in find_examples(&text, &filename).into_iter().enumerate() {
if attr == "norun" { if attr == "norun" {