/// Validates a spec into a (possibly empty) set of runnable tests.
Validates a spec into a (possibly empty) set of runnable tests.
Validates a spec into a ( possibly empty ) set of runnable tests .
pub fn validate(spec: TestSpec) -> Result<Vec<Test>> {
    for &exclude in EXCLUDED_LABELS {
        if spec.labels.contains(exclude) {
            return Ok(vec![]);
        }
    }
    // we'll collect all validation errors we can find
    let mut error = String::new();
    if spec.command.len() < 1 {
        let msg = format!("    Error: Empty command line\n");
        error.push_str(&msg);
    }
    // if requirements were specified, we better verify they're there
    for req in spec.required_paths.clone().unwrap_or(vec![]) {
        if !req.exists() {
            let msg = format!("    Error: Missing requirement {}\n", req.display());
            error.push_str(&msg);
        }
    }
    if !error.is_empty() {
        bail!("Invalid context for test target {}\n{}", spec.target, error);
    }
    // dispatch on kind for further processing
    let tests = match spec.kind {
        TestKind::Pyunit => pyunit::list_tests(spec),
        TestKind::Rust => rust::list_tests(spec),
        TestKind::Shell => shell::list_tests(spec),
    };
    return Ok(tests);
}
pub fn validate ( spec : TestSpec ) -> Result < Vec < Test > > { for & exclude in EXCLUDED_LABELS { if spec . labels . contains ( exclude ) { return Ok ( vec ! [ ] ) ; } } // we'll collect all validation errors we can find let mut error = String :: new ( ) ; if spec . command . len ( ) < 1 { let msg = format ! ( " \n " ) ; error . push_str ( & msg ) ; } // if requirements were specified, we better verify they're there for req in spec . required_paths . clone ( ) . unwrap_or ( vec ! [ ] ) { if ! req . exists ( ) { let msg = format ! ( " \n " req display ( ) ) ; error . push_str ( & msg ) ; } } if ! error . is_empty ( ) { bail ! ( " \n " spec target error ) ; } // dispatch on kind for further processing let tests = match spec . kind { TestKind :: Pyunit => pyunit :: list_tests ( spec ) , TestKind :: Rust => rust :: list_tests ( spec ) , TestKind :: Shell => shell :: list_tests ( spec ) , } ; return Ok ( tests ) ; }
Validates a spec into a (possibly empty) set of runnable tests.
Validates a spec into a ( possibly empty ) set of runnable tests .
spec
TestSpec