1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use regex::Regex;
use std::{fs::File, io::Read, path::Path};
pub mod baseline_test;
pub const DEFAULT_SENDER: &str = "0x8675309";
pub fn extract_test_directives(path: &Path, start: &str) -> anyhow::Result<Vec<String>> {
let rex = Regex::new(&format!("(?m)^{}(?P<ann>.*?)$", start)).unwrap();
let mut content = String::new();
let mut file = File::open(path)?;
file.read_to_string(&mut content)?;
let mut at = 0;
let mut res = vec![];
while let Some(cap) = rex.captures(&content[at..]) {
res.push(cap.name("ann").unwrap().as_str().trim().to_string());
at += cap.get(0).unwrap().end();
}
Ok(res)
}