2 releases
0.1.1 | Apr 8, 2023 |
---|---|
0.1.0 | Apr 8, 2023 |
#12 in #anything
35 downloads per month
Used in tap_runner
70KB
1.5K
SLoC
TAP Parser
This library implements a parser for the Test Anything Protocol.
It implements only the TAP version 14. It should implement all features, including subtests. Pragmas are ignored.
There are two examples in the examples
, json
outputs the TAP document as json, and parse
outputs a debug representation.
lib.rs
:
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(),
}),
]
);
Dependencies
~255–770KB
~18K SLoC