|
Porytiles
|
Testing implementation of UserDiagnostics that buffers all diagnostic output. More...
#include <buffered_user_diagnostics.hpp>
Public Member Functions | |
| BufferedUserDiagnostics () | |
| Construct a BufferedUserDiagnostics with a PlainTextFormatter. | |
| void | remark (const std::string &tag, const std::vector< std::string > &lines) const override |
| Display a tagged remark message. | |
| void | remark_note (const std::string &tag, const std::vector< std::string > &lines) const override |
| Display a tagged note message associated with a remark. | |
| void | warning_note (const std::string &tag, const std::vector< std::string > &lines) const override |
| Display a tagged note message associated with a warning. | |
| void | error_note (const std::string &tag, const std::vector< std::string > &lines) const override |
| Display a tagged note message associated with an error. | |
| void | warning (const std::string &tag, const std::vector< std::string > &lines) const override |
| Display a tagged warning message. | |
| void | error (const std::string &tag, const std::vector< std::string > &lines) const override |
| Display a tagged error message. | |
| void | emit_fatal_proximate (const Error &err) const override |
| Emit the proximate (immediate) error in a fatal error chain. | |
| void | emit_fatal_step (const Error &err) const override |
| Emit an intermediate step error in a fatal error chain. | |
| void | emit_fatal_root (const Error &err) const override |
| Emit the root cause error in a fatal error chain. | |
| const std::vector< std::vector< std::string > > & | remarks () const |
| Get the buffered remark messages. | |
| const std::vector< std::vector< std::string > > & | remark_notes () const |
| Get the buffered remark-associated note messages. | |
| const std::vector< std::vector< std::string > > & | warning_notes () const |
| Get the buffered warning-associated note messages. | |
| const std::vector< std::vector< std::string > > & | error_notes () const |
| Get the buffered error-associated note messages. | |
| const std::vector< std::vector< std::string > > & | warnings () const |
| Get the buffered warning messages. | |
| const std::vector< std::vector< std::string > > & | errors () const |
| Get the buffered error messages. | |
| const std::vector< std::vector< std::string > > & | fatal_proximates () const |
| Get the buffered fatal proximate error messages. | |
| const std::vector< std::vector< std::string > > & | fatal_steps () const |
| Get the buffered fatal step error messages. | |
| const std::vector< std::vector< std::string > > & | fatal_roots () const |
| Get the buffered fatal root error messages. | |
| const std::map< std::string, size_t > & | remark_tag_counts () const |
| Get the count of remark messages by tag. | |
| const std::map< std::string, size_t > & | remark_note_tag_counts () const |
| Get the count of remark-associated note messages by tag. | |
| const std::map< std::string, size_t > & | warning_note_tag_counts () const |
| Get the count of warning-associated note messages by tag. | |
| const std::map< std::string, size_t > & | error_note_tag_counts () const |
| Get the count of error-associated note messages by tag. | |
| const std::map< std::string, size_t > & | warning_tag_counts () const |
| Get the count of warn messages by tag. | |
| const std::map< std::string, size_t > & | error_tag_counts () const |
| Get the count of error messages by tag. | |
Public Member Functions inherited from porytiles::UserDiagnostics | |
| virtual | ~UserDiagnostics ()=default |
| UserDiagnostics (gsl::not_null< const TextFormatter * > format) | |
| void | remark (const std::string &tag, const std::string &msg) const |
| Convenience overload for single line messages. | |
| template<typename FirstParam , typename... RestParams> requires ( !std::is_same_v<std::decay_t<FirstParam>, std::vector<FormatParam>> && std::is_constructible_v<FormatParam, FirstParam> && (std::is_constructible_v<FormatParam, RestParams> && ...)) | |
| void | remark (const std::string &tag, const std::string &format_str, FirstParam &&first, RestParams &&...rest) const |
| Variadic template overload for formatted remark messages. | |
| void | warning (const std::string &tag, const std::string &msg) const |
| Convenience overload for single line messages. | |
| template<typename FirstParam , typename... RestParams> requires ( !std::is_same_v<std::decay_t<FirstParam>, std::vector<FormatParam>> && std::is_constructible_v<FormatParam, FirstParam> && (std::is_constructible_v<FormatParam, RestParams> && ...)) | |
| void | warning (const std::string &tag, const std::string &format_str, FirstParam &&first, RestParams &&...rest) const |
| Variadic template overload for formatted warning messages. | |
| void | error (const std::string &tag, const std::string &msg) const |
| Convenience overload for single line messages. | |
| template<typename FirstParam , typename... RestParams> requires ( !std::is_same_v<std::decay_t<FirstParam>, std::vector<FormatParam>> && std::is_constructible_v<FormatParam, FirstParam> && (std::is_constructible_v<FormatParam, RestParams> && ...)) | |
| void | error (const std::string &tag, const std::string &format_str, FirstParam &&first, RestParams &&...rest) const |
| Variadic template overload for formatted error messages. | |
| void | remark_note (const std::string &tag, const std::string &msg) const |
| Convenience overload for single line messages. | |
| template<typename FirstParam , typename... RestParams> requires ( !std::is_same_v<std::decay_t<FirstParam>, std::vector<FormatParam>> && std::is_constructible_v<FormatParam, FirstParam> && (std::is_constructible_v<FormatParam, RestParams> && ...)) | |
| void | remark_note (const std::string &tag, const std::string &format_str, FirstParam &&first, RestParams &&...rest) const |
| Variadic template overload for formatted remark note messages. | |
| void | warning_note (const std::string &tag, const std::string &msg) const |
| Convenience overload for single line messages. | |
| template<typename FirstParam , typename... RestParams> requires ( !std::is_same_v<std::decay_t<FirstParam>, std::vector<FormatParam>> && std::is_constructible_v<FormatParam, FirstParam> && (std::is_constructible_v<FormatParam, RestParams> && ...)) | |
| void | warning_note (const std::string &tag, const std::string &format_str, FirstParam &&first, RestParams &&...rest) const |
| Variadic template overload for formatted warning note messages. | |
| void | error_note (const std::string &tag, const std::string &msg) const |
| Convenience overload for single line messages. | |
| template<typename FirstParam , typename... RestParams> requires ( !std::is_same_v<std::decay_t<FirstParam>, std::vector<FormatParam>> && std::is_constructible_v<FormatParam, FirstParam> && (std::is_constructible_v<FormatParam, RestParams> && ...)) | |
| void | error_note (const std::string &tag, const std::string &format_str, FirstParam &&first, RestParams &&...rest) const |
| Variadic template overload for formatted error note messages. | |
| template<typename T , typename E > | |
| void | fatal (const ChainableResult< T, E > &result) const |
| Display a fatal error with complete error chain visualization. | |
| const TextFormatter & | formatter () const |
Testing implementation of UserDiagnostics that buffers all diagnostic output.
BufferedUserDiagnostics provides a test-friendly implementation of the UserDiagnostics interface that stores all diagnostic messages in memory buffers instead of outputting them. This enables unit tests to verify that appropriate diagnostic messages were generated during execution.
Each diagnostic type (notes, warnings, errors, etc.) is stored in its own dedicated buffer as a vector of message lines. Tests can access these buffers to verify both the presence and content of diagnostic messages.
In addition to storing the full diagnostic messages, this class maintains count maps that track how many times each tag was used for each diagnostic type. This allows tests to quickly verify that the expected number of diagnostics with specific tags were emitted, without needing to iterate through all buffered messages. For example, tests can check that exactly 3 errors with tag "INVALID_INPUT" were generated by accessing the error_tag_counts() map.
This implementation is intended exclusively for testing scenarios where diagnostic output needs to be captured and inspected programmatically.
Definition at line 33 of file buffered_user_diagnostics.hpp.
|
inline |
Construct a BufferedUserDiagnostics with a PlainTextFormatter.
Creates a PlainTextFormatter for use in formatting error details. Since this class is intended for testing scenarios where diagnostic output needs to be captured and inspected, plain text formatting (no ANSI styling) is always used.
Definition at line 43 of file buffered_user_diagnostics.hpp.
|
overridevirtual |
Emit the proximate (immediate) error in a fatal error chain.
Virtual method for displaying the most immediate error in a fatal error chain. This is typically the first error encountered and is displayed with the highest visual prominence.
| err | The proximate error to display |
Implements porytiles::UserDiagnostics.
Definition at line 46 of file buffered_user_diagnostics.cpp.
|
overridevirtual |
Emit the root cause error in a fatal error chain.
Virtual method for displaying the root cause error in a fatal error chain. This represents the original underlying cause of the failure and is typically displayed as the final item in the error hierarchy.
| err | The root cause error to display |
Implements porytiles::UserDiagnostics.
Definition at line 56 of file buffered_user_diagnostics.cpp.
|
overridevirtual |
Emit an intermediate step error in a fatal error chain.
Virtual method for displaying intermediate errors in a fatal error chain. These are errors that occurred between the proximate and root causes, typically displayed with tree-like formatting to show the error hierarchy.
| err | The step error to display |
Implements porytiles::UserDiagnostics.
Definition at line 51 of file buffered_user_diagnostics.cpp.
|
overridevirtual |
Display a tagged error message.
Errors indicate serious issues that require attention but don't necessarily cause immediate failure of the current operation. They include a categorization tag to help users understand and/or filter the type of error being reported.
Implementations typically format the first line with an "error:" prefix and subsequent lines with appropriate indentation.
| tag | Categorization tag for the error |
| lines | Vector of strings representing each line of the error |
Implements porytiles::UserDiagnostics.
Definition at line 40 of file buffered_user_diagnostics.cpp.
|
overridevirtual |
Display a tagged note message associated with an error.
Notes are informational messages that further clarify a parent diagnostic. This method is specifically for notes that follow an error diagnostic, enabling proper filtering - when an error is filtered out, its associated notes can also be suppressed.
Implementations typically format the first line with a "note:" prefix and subsequent lines with appropriate indentation. All note types use identical styling regardless of parent diagnostic type.
| tag | Categorization tag for the note (should match the parent error's tag) |
| lines | Vector of strings representing each line of the message |
Implements porytiles::UserDiagnostics.
Definition at line 28 of file buffered_user_diagnostics.cpp.
|
inline |
Get the count of error-associated note messages by tag.
Returns a reference to a map that tracks how many times each tag was used in calls to error_note(). The keys are tag strings and the values are the number of times each tag appeared.
Definition at line 241 of file buffered_user_diagnostics.hpp.
|
inline |
Get the buffered error-associated note messages.
Returns a reference to the vector containing all note messages that were passed to error_note(). Each element represents one call to error_note(), stored as a vector of lines.
Definition at line 114 of file buffered_user_diagnostics.hpp.
|
inline |
Get the count of error messages by tag.
Returns a reference to a map that tracks how many times each tag was used in calls to err(). The keys are tag strings and the values are the number of times each tag appeared.
Definition at line 269 of file buffered_user_diagnostics.hpp.
|
inline |
Get the buffered error messages.
Returns a reference to the vector containing all error messages that were passed to err(). Each element represents one call to err(), stored as a vector of lines.
Definition at line 142 of file buffered_user_diagnostics.hpp.
|
inline |
Get the buffered fatal proximate error messages.
Returns a reference to the vector containing all fatal proximate error messages that were passed to emit_fatal_proximate(). Each element represents one call to emit_fatal_proximate(), stored as a vector of message lines.
Definition at line 157 of file buffered_user_diagnostics.hpp.
|
inline |
Get the buffered fatal root error messages.
Returns a reference to the vector containing all fatal root error messages that were passed to emit_fatal_root(). Each element represents one call to emit_fatal_root(), stored as a vector of message lines.
Definition at line 185 of file buffered_user_diagnostics.hpp.
|
inline |
Get the buffered fatal step error messages.
Returns a reference to the vector containing all fatal step error messages that were passed to emit_fatal_step(). Each element represents one call to emit_fatal_step(), stored as a vector of message lines.
Definition at line 171 of file buffered_user_diagnostics.hpp.
|
overridevirtual |
Display a tagged remark message.
Remarks are the lowest severity diagnostic level, used for communicating internal compiler mechanisms or decisions that may be of interest to users. Unlike notes (which clarify other remarks/warnings/errors), remarks are standalone informational messages about compiler behavior such as optimization decisions, tile assignment choices, or palette allocation strategies.
Implementations typically format the first line with a "remark:" prefix and the tag, with subsequent lines appropriately indented.
| tag | Categorization tag for the remark |
| lines | Vector of strings representing each line of the message |
Implements porytiles::UserDiagnostics.
Definition at line 10 of file buffered_user_diagnostics.cpp.
|
overridevirtual |
Display a tagged note message associated with a remark.
Notes are informational messages that further clarify a parent diagnostic. This method is specifically for notes that follow a remark diagnostic, enabling proper filtering - when a remark is filtered out, its associated notes can also be suppressed.
Implementations typically format the first line with a "note:" prefix and subsequent lines with appropriate indentation. All note types use identical styling regardless of parent diagnostic type.
| tag | Categorization tag for the note (should match the parent remark's tag) |
| lines | Vector of strings representing each line of the message |
Implements porytiles::UserDiagnostics.
Definition at line 16 of file buffered_user_diagnostics.cpp.
|
inline |
Get the count of remark-associated note messages by tag.
Returns a reference to a map that tracks how many times each tag was used in calls to remark_note(). The keys are tag strings and the values are the number of times each tag appeared.
Definition at line 213 of file buffered_user_diagnostics.hpp.
|
inline |
Get the buffered remark-associated note messages.
Returns a reference to the vector containing all note messages that were passed to remark_note(). Each element represents one call to remark_note(), stored as a vector of lines.
Definition at line 86 of file buffered_user_diagnostics.hpp.
|
inline |
Get the count of remark messages by tag.
Returns a reference to a map that tracks how many times each tag was used in calls to remark(). The keys are tag strings and the values are the number of times each tag appeared.
Definition at line 199 of file buffered_user_diagnostics.hpp.
|
inline |
Get the buffered remark messages.
Returns a reference to the vector containing all remark messages that were passed to remark(). Each element represents one call to remark(), stored as a vector of lines.
Definition at line 72 of file buffered_user_diagnostics.hpp.
|
overridevirtual |
Display a tagged warning message.
Warnings indicate non-fatal issues that users should be aware of. They include a categorization tag to help users understand and/or filter the type of warning being reported.
Implementations typically format the first line with a "warning:" prefix and the tag, with subsequent lines appropriately indented.
| tag | Categorization tag for the warning |
| lines | Vector of strings representing each line of the warning |
Implements porytiles::UserDiagnostics.
Definition at line 34 of file buffered_user_diagnostics.cpp.
|
overridevirtual |
Display a tagged note message associated with a warning.
Notes are informational messages that further clarify a parent diagnostic. This method is specifically for notes that follow a warning diagnostic, enabling proper filtering - when a warning is filtered out, its associated notes can also be suppressed.
Implementations typically format the first line with a "note:" prefix and subsequent lines with appropriate indentation. All note types use identical styling regardless of parent diagnostic type.
| tag | Categorization tag for the note (should match the parent warning's tag) |
| lines | Vector of strings representing each line of the message |
Implements porytiles::UserDiagnostics.
Definition at line 22 of file buffered_user_diagnostics.cpp.
|
inline |
Get the count of warning-associated note messages by tag.
Returns a reference to a map that tracks how many times each tag was used in calls to warning_note(). The keys are tag strings and the values are the number of times each tag appeared.
Definition at line 227 of file buffered_user_diagnostics.hpp.
|
inline |
Get the buffered warning-associated note messages.
Returns a reference to the vector containing all note messages that were passed to warning_note(). Each element represents one call to warning_note(), stored as a vector of lines.
Definition at line 100 of file buffered_user_diagnostics.hpp.
|
inline |
Get the count of warn messages by tag.
Returns a reference to a map that tracks how many times each tag was used in calls to warn(). The keys are tag strings and the values are the number of times each tag appeared.
Definition at line 255 of file buffered_user_diagnostics.hpp.
|
inline |
Get the buffered warning messages.
Returns a reference to the vector containing all warning messages that were passed to warn(). Each element represents one call to warn(), stored as a vector of lines.
Definition at line 128 of file buffered_user_diagnostics.hpp.