TTS v3.0.0
The Tiny Test System
Loading...
Searching...
No Matches
tts::gathering_sink Struct Reference

output_sink gathering every message into a single retrievable buffer. More...

Detailed Description

output_sink gathering every message into a single retrievable buffer.

Instead of streaming messages as they are written, gathering_sink accumulates them into a single tts::text. That buffer can be inspected at any time via content(), streamed out at once via dump(), or discarded via clear().

Example

// ... run the test suite ...
report.dump(); // stream everything gathered so far to stdout
// or
report.dump(some_other_sink); // forward it to another output_sink instead
// or
do_something_with(report.content()); // retrieve it to do something else entirely
void sink(output_sink &s)
Installs s as the output_sink every subsequent write goes to.
Definition output.hpp:379
int report(unsigned long long fails, unsigned long long invalids)
Test reporting customization point.
Definition environment.hpp:139
output_handler & output()
Retrieves the current TTS output_handler.
Definition output.hpp:414
output_sink gathering every message into a single retrievable buffer.
Definition output.hpp:234

Public Member Functions

virtual void assertion_failed (text const &location, text const &message, bool fatal)
void clear ()
 Discards everything gathered so far.
text const & content () const
 Retrieves everything gathered so far.
void dump ()
 Streams everything gathered so far to stdout, then clears the buffer.
void dump (output_sink &target)
 Forwards everything gathered so far to target, then clears the buffer.
virtual void finish ()
virtual void flush ()
 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()

virtual void tts::output_sink::assertion_failed ( text const & location,
text const & message,
bool fatal )
inlinevirtualinherited

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