Skip to main content

parse_crate_binaries

Function parse_crate_binaries 

Source
pub fn parse_crate_binaries(text: &str) -> Vec<(String, Outcome, u64)>
Expand description

One Running tests/<name>.rs / test result: pair per test binary, joined: the binaries of read_crate_output as (name, outcome, seconds), without what it listed.

use majordomus_cli::evidence::parse_crate_binaries;
let out = "   Running tests/why.rs (target/debug/deps/why-1a2b)\n\
            test result: ok. 12 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; \
            finished in 0.41s\n\
               Running tests/product.rs (target/debug/deps/product-3c4d)\n\
            test result: FAILED. 3 passed; 1 failed; 0 ignored; 0 measured\n";
let got = parse_crate_binaries(out);
assert_eq!(got.len(), 2);
assert_eq!(got[0].0, "why");
assert!(got[0].1.proves());
assert_eq!(got[1].0, "product");
assert!(!got[1].1.proves());
use majordomus_cli::evidence::parse_crate_binaries;
assert!(parse_crate_binaries("nothing to see here").is_empty());

The outputs of several lanes are joined end to end, so a binary whose run was cut short must not take the next result line, a doctest run’s least of all: it stands as an error that ran nothing, and the doctest result belongs to no binary.

use majordomus_cli::evidence::{parse_crate_binaries, Outcome};
let joined = "     Running tests/cut.rs (target/debug/deps/cut-1a2b)\n\
                 Doc-tests majordomus_cli\n\
              test result: ok. 900 passed; 0 failed; finished in 600.00s\n";
assert_eq!(parse_crate_binaries(joined), [("cut".to_string(), Outcome::Error, 0)]);