Crate tap_parser

source ·
Expand description

This crate is a parser for the Test Anything Protocol.

It handles all the TAP 14 features, including subtests. The main entrypoint is the TapParser structure.

The parser will ignore trailing lines when it is sure it could not be in the TAP document anymore.

Example

use tap_parser::{TapParser, TapStatement, TapPlan, TapTest};

let document = "TAP version 14\n1..1\nok 1 - success\nnot ok 2 - fail";
let mut parser = TapParser::new();
assert_eq!(
    parser.parse(document).unwrap(),
    vec![
        TapStatement::Plan(TapPlan {
            count: 1,
            reason: None
        }),
        TapStatement::TestPoint(TapTest {
            result: true,
            number: Some(1),
            desc: Some("success"),
            directive: None,
            yaml: Vec::new(),
        }),
        TapStatement::TestPoint(TapTest {
            result: false,
            number: Some(2),
            desc: Some("fail"),
            directive: None,
            yaml: Vec::new(),
        }),
    ]
);

Structs

Enums