What you think about:
Detailed design
Replace current, human-readable, output with JSON-based output based on TAP-J. For compatibility with existing work flow there should be added built-in parser for that protocol which will output in current format.
The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in RFC 2119.
Protocol description
Output of test suite should be stream of JSON objects that can be parsed by additional tooling.
Structure
Output is stream lines containing JSON objects separated by new line. Each object MUST contain type field which designates suite, test, bench or finally. Any document MAY have extra field which contains an open mapping for additional information.
Suite
{
"type": "suite",
"name": "Doc-Test",
"build": "2015-08-21T10:03:20+0200",
"count": 13,
"rustc": "2a89bb6ba033b236c79a90486e2e3ee04d0e66f9"
}
Describe test suite. It MUST appear only once at the beginning of stream.
Fields:
-
type MUST be suite.
-
build MUST be ISO8601 timestamp of build date. It will prevent accidentally running old test suites at zero cost.
-
name SHOULD contain current suite type (“Test”, “Doc-Test”, “Benchmark”).
-
count MUST be count of all tests (including ignored in runtime)
-
rustc MUST be version of Rust compiler used for building test suite.
Test
{
"type": "test",
"subtype": "should_panic",
"status": "ok",
"label": "octavo::digest::md5::tests::test_md5",
"file": "src/digest/md5.rs",
"line": 684,
"stdout": "",
"stderr": "",
"duration": 100
}
Each test MUST have produce one and only one test struct.
Test unit MUST have status field which MUST be one of the values: ok, fail, ignore.
It is RECOMMENDED to add subtype field which contain either test, bench or should_panic.
Unit MUST also contain label field which describe name of the test.
A test SHOULD contain file and line fields for sake of debugging.
A test MAY contain stdout and stderr that are outputs on given streams.
It is RECOMMENDED to include duration field that contain test run time in nanosecond .
Benchmark
{
"type": "bench",
"status": "ok",
"label": "octavo::digest::md5::tests::bench_md5",
"file": "src/digest/md5.rs",
"line": 698,
"iterations": 382,
"duration": 300
}
Fields description is the same as in test with 2 conditions:
-
duration field MUST be present
- additional
iterations field MUST be present that presents iterations measured by benchmark
Finally
{
"type": "final",
"results": {
"ok": 10,
"fail": 0,
"ignore": 2
}
}
This MUST finish the stream and parser MUST reject all input that will be after this structure.
results struct MUST include all fields named ok, fail and ignore which describe how many tests passed, failed and was ignored respectfully.