epitls-pi/src/test.rs
2022-09-24 21:54:34 +02:00

29 lines
570 B
Rust

pub fn main(_capture: bool, _files: Vec<String>, _test: Option<String>) {
let content = todo!();
let tests = find_tests(content);
for test in tests {
// compile
// run
}
}
pub fn find_tests(source: String) -> Vec<String> {
source
.split([' ', '(', ')', ';'])
.filter(|name| &name[0..5] == "test_")
.map(String::from)
.collect()
}
pub fn gen_test_main(test_file: &str, test: &str) -> String {
format!(
"
#include \"{test_file}\"
int main() {{
{test}();
return 0;
}}
"
)
}