NAME
test/parser - Parse TAP output and summarize test counts.
SYNOPSIS
from test/parser import parse;
let tap := "ok 1 - alpha\nnot ok 2 - beta\n1..2\n";
let summary := parse( tap );
# Top-level counts
say( summary{top_level}{passed} );
# All assertions, including nested subtests
say( summary{assertions}{failed} );
# Top-level plan, if present
say( summary{planned} );
IMPLEMENTATION SUPPORT
This module is supported by all implementations of ZuzuScript.
DESCRIPTION
test/parser parses lines in TAP (Test Anything Protocol) format and returns a summary dictionary.
The summary tracks:
- Top-level assertion outcomes.
A top-level assertion is any
ok ...ornot ok ...line with no subtest indentation. A subtest block therefore counts as one top-level test via the parent assertion line. - Total assertion outcomes across all levels.
This includes assertions inside subtests, including nested subtests.
- Planned top-level test count.
This is the final number from a top-level
1..Nplan line, ornullif no top-level plan is present. - Parsed test assertion rows.
Each parsed assertion is appended to
tests, including whether it is at top level and its parsed number/description metadata.
Outcome buckets are mutually exclusive and reported as passed, failed, todo, and skipped. If an assertion line has a TODO or SKIP directive, it is counted in that bucket rather than pass/fail.
EXPORTS
Functions
parse(String tap)Parameters:
tapis TAP output text. Returns:Dict. Parses a TAP string and returns a summary dictionary.parse_lines(Array lines)Parameters:
linesis an array of TAP lines. Returns:Dict. Parses TAP from already-split lines and returns the same summary dictionary asparse.
COPYRIGHT AND LICENCE
test/parser is copyright Toby Inkster.
It is free software; you may redistribute it and/or modify it under the terms of either the Artistic License 1.0 or the GNU General Public License version 2.