clitest/
lib.rs

1#![feature(variant_count)]
2#![feature(lazy_cell)]
3
4use ::std::fs::read_to_string;
5
6use ::log::debug;
7
8use crate::parse::CliTest;
9use crate::scan::find_cli_tests;
10
11pub use self::cli::Args;
12
13mod common;
14mod cli;
15mod scan;
16mod parse;
17
18pub fn cli_test(args: &Args) -> Result<(), String> {
19    assert!(!args.roots.is_empty());
20    let tests = collect_tests(args)?;
21    todo!("run")
22}
23
24fn collect_tests(args: &Args) -> Result<Vec<CliTest>, String> {
25    if 1==1 { return Err("cli-test is under development and not ready for use yet".to_owned()) }
26    let paths = match args.path.as_ref() {
27        Some(pth) => {
28            debug!("requested cli-test for file {}, not scanning for more tests", pth.to_string_lossy());
29            vec![pth.to_owned()]
30        },
31        None => find_cli_tests(&args.roots, args.max_depth, args.minimum_tests)?,
32    };
33    let mut tests = Vec::with_capacity(paths.len());
34    for path in paths {
35        let content = read_to_string(&path)
36            .map_err(|err| format!("could not read cli-test at '{}', err {err}", path.to_string_lossy()))?;
37        tests.push(CliTest::parse(&content, &path)?)
38    }
39    Ok(tests)
40}