output_sink rendering the run as a single structured JSON document. More...
output_sink rendering the run as a single structured JSON document.
Built from output_sink's structured hooks rather than by parsing the human-readable text tts::stdout_sink prints, so it stays correct regardless of -v/-q. Every TTS_CASE becomes one entry in a "tests" array (name, status, duration in nanoseconds, and any failing/fatal assertions gathered while it ran), summarized by a "summary" object counting passed/failed/invalid cases - counted from test_finished() directly, not from the suite's raw assertion totals, so tests.length always matches summary.total. Rendered by dump(), or automatically via finish(), to the target given at construction (tts::output_handler::default_sink() by default). It does not (currently) reflect TTS_CASE_TPL's per-type breakdown or TTS_WHEN / TTS_AND_THEN sub-scenarios, since those don't have their own hook - only the enclosing TTS_CASE does.
Public Member Functions | |
| void | assertion_failed (text const &location, text const &message, bool fatal) override |
| void | clear () |
| Discards everything gathered so far. | |
| void | dump () |
| Streams the JSON-rendered report to stdout, then clears the gathered results. | |
| void | dump (output_sink &target) |
| Forwards the JSON-rendered report to target, then clears the gathered results. | |
| void | finish () override |
| Dumps the JSON-rendered report to the target given at construction. | |
| virtual void | flush () |
| Flushes this sink's destination, if that means anything for it. No-op by default. | |
| text | render () const |
| Renders everything gathered so far as a single JSON document. | |
| virtual void | suite_aborted () |
| virtual void | suite_finished (unsigned long long fail_count, unsigned long long invalid_count) |
| virtual void | suite_metric (outcome kind, unsigned long long count, unsigned long long total) |
| void | test_finished (text const &name, bool passed, bool invalid, unsigned long long duration_ns) override |
| virtual void | test_started (text const &name) |
| void | write (text const &) override |
| Writes t to this sink's destination. | |
|
inlineoverridevirtual |
Called once per failing/fatal assertion, always and before the corresponding text (if any - it's suppressed under -q for a plain failure, though never for a fatal one). No-op by default. Not called for passing assertions - test_finished()'s passed already covers that case, and most consumers of this hook don't want one event per assertion.
Reimplemented from tts::output_sink.
|
inlinevirtualinherited |
Called if the suite aborts early due to a TTS_FATAL failure, before tts::report() (and thus suite_finished()) runs. No-op by default.
Reimplemented in tts::colorized_sink.
|
inlinevirtualinherited |
Called once the whole suite has finished running (from tts::report()), with its aggregate outcome, always - even under -q. No-op by default.
Reimplemented in tts::colorized_sink.
|
inlinevirtualinherited |
Called once per non-zero outcome category, right before its "N/M (P%) <label>" segment is printed as part of the Results: ... summary. No-op by default.
Reimplemented in tts::colorized_sink.
|
inlineoverridevirtual |
Called once a TTS_CASE / TTS_CASE_TPL / TTS_CASE_WITH has finished running, always and before its corresponding text (if any - suppressed under -q), with its outcome and how long it took to run, in nanoseconds. No-op by default.
Reimplemented from tts::output_sink.
|
inlinevirtualinherited |
Called when a TTS_CASE / TTS_CASE_TPL / TTS_CASE_WITH is about to run. No-op by default - opt-in for sinks that want structured per-test events instead of (or in addition to) parsing the formatted text stream.
Reimplemented in tts::colorized_sink.