TTS v3.0.0
The Tiny Test System
Loading...
Searching...
No Matches

output_sink adding compiler-style diagnostics for every failing/fatal assertion. More...

Detailed Description

output_sink adding compiler-style diagnostics for every failing/fatal assertion.

Forwards every message to a target sink (tts::output_handler::default_sink() by default) unchanged, and additionally prints one path:line: error: message / path:line: fatal error: message line per failing/fatal assertion - built from output_sink's structured assertion_failed() hook, not by parsing text - so editors/IDEs with a GCC/Clang-style problem matcher (VS Code's C/C++ extension provides $gcc, vim has quickfix, ...) can jump straight to it. Prints even under -q, when the raw failure line it complements is itself suppressed.

Example

tts::output().sink(diagnostics);
void sink(output_sink &s)
Installs s as the output_sink every subsequent write goes to.
Definition output.hpp:379
output_handler & output()
Retrieves the current TTS output_handler.
Definition output.hpp:414
output_sink adding compiler-style diagnostics for every failing/fatal assertion.
Definition diagnostics.hpp:37

Public Member Functions

void assertion_failed (text const &location, text const &message, bool fatal) override
virtual void finish ()
void flush () override
 Flushes this sink's destination, if that means anything for it. No-op by default.
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)
virtual void test_finished (text const &name, bool passed, bool invalid, unsigned long long duration_ns)
virtual void test_started (text const &name)
void write (text const &t) override
 Writes t to this sink's destination.

Member Function Documentation

◆ assertion_failed()

void tts::diagnostics_sink::assertion_failed ( text const & location,
text const & message,
bool fatal )
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.

◆ finish()

virtual void tts::output_sink::finish ( )
inlinevirtualinherited

Called once, after tts::report() returns - every other hook has already fired by then - so an accumulate-style sink (e.g. tts::tap_sink) can render and flush its buffered content to its own destination. No-op by default: pass-through sinks that already forward write() as it happens (e.g. tts::colorized_sink) have nothing left to do here. Like --shard, this is only called by the default driver (TTS_MAIN) - a TTS_CUSTOM_DRIVER_FUNCTION manages whichever sink it installed itself, including dumping it, so its driver never calls finish() on its own.

Reimplemented in tts::json_sink, tts::junit_sink, and tts::tap_sink.

◆ suite_aborted()

virtual void tts::output_sink::suite_aborted ( )
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.

◆ suite_finished()

virtual void tts::output_sink::suite_finished ( unsigned long long fail_count,
unsigned long long invalid_count )
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.

◆ suite_metric()

virtual void tts::output_sink::suite_metric ( outcome kind,
unsigned long long count,
unsigned long long total )
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.

◆ test_finished()

virtual void tts::output_sink::test_finished ( text const & name,
bool passed,
bool invalid,
unsigned long long duration_ns )
inlinevirtualinherited

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 in tts::colorized_sink, tts::json_sink, tts::junit_sink, and tts::tap_sink.

◆ test_started()

virtual void tts::output_sink::test_started ( text const & name)
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.