diff options
author | Moritz Pflanzer <moritz.pflanzer@arm.com> | 2017-08-04 11:34:44 +0100 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-09-17 14:16:42 +0100 |
commit | 24a82463b683322a6bb11a103746ea9d9b3f53fb (patch) | |
tree | a444ba8dcc8c3cddd2540e722de49de7c0676e73 /framework/printers | |
parent | 4dfc235367e602a366952a8495679e339d7a7263 (diff) | |
download | ComputeLibrary-24a82463b683322a6bb11a103746ea9d9b3f53fb.tar.gz |
COMPMID-415: Use printer for errors
Change-Id: Idc2fc1dfd5706580d15c2bbfffe2830d41075a4b
Reviewed-on: http://mpd-gerrit.cambridge.arm.com/82908
Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com>
Diffstat (limited to 'framework/printers')
-rw-r--r-- | framework/printers/JSONPrinter.cpp | 27 | ||||
-rw-r--r-- | framework/printers/JSONPrinter.h | 7 | ||||
-rw-r--r-- | framework/printers/PrettyPrinter.cpp | 13 | ||||
-rw-r--r-- | framework/printers/PrettyPrinter.h | 3 | ||||
-rw-r--r-- | framework/printers/Printer.h | 13 |
5 files changed, 62 insertions, 1 deletions
diff --git a/framework/printers/JSONPrinter.cpp b/framework/printers/JSONPrinter.cpp index 7806644418..3408174b48 100644 --- a/framework/printers/JSONPrinter.cpp +++ b/framework/printers/JSONPrinter.cpp @@ -78,6 +78,7 @@ void JSONPrinter::print_test_header(const TestInfo &info) { print_separator(_first_test); + _first_test_entry = true; *_stream << R"(")" << info.name << R"(" : {)"; } @@ -86,8 +87,32 @@ void JSONPrinter::print_test_footer() *_stream << "}"; } +void JSONPrinter::print_errors_header() +{ + print_separator(_first_test_entry); + + _first_error = true; + *_stream << R"("errors" : [)"; +} + +void JSONPrinter::print_errors_footer() +{ + *_stream << "]"; +} + +void JSONPrinter::print_error(const std::exception &error) +{ + print_separator(_first_error); + + *_stream << R"(")" << error.what() << R"(")"; +} + void JSONPrinter::print_measurements(const Profiler::MeasurementsMap &measurements) { + print_separator(_first_test_entry); + + *_stream << R"("measurements" : {)"; + for(auto i_it = measurements.cbegin(), i_end = measurements.cend(); i_it != i_end;) { *_stream << R"(")" << i_it->first << R"(" : {)"; @@ -129,6 +154,8 @@ void JSONPrinter::print_measurements(const Profiler::MeasurementsMap &measuremen *_stream << ","; } } + + *_stream << "}"; } } // namespace framework } // namespace test diff --git a/framework/printers/JSONPrinter.h b/framework/printers/JSONPrinter.h index 7b34941ca1..14c8b35cb9 100644 --- a/framework/printers/JSONPrinter.h +++ b/framework/printers/JSONPrinter.h @@ -45,13 +45,18 @@ public: void print_run_footer() override; void print_test_header(const TestInfo &info) override; void print_test_footer() override; + void print_errors_header() override; + void print_errors_footer() override; + void print_error(const std::exception &error) override; void print_measurements(const Profiler::MeasurementsMap &measurements) override; private: void print_separator(bool &flag); - bool _first_test{ true }; bool _first_entry{ true }; + bool _first_test{ true }; + bool _first_test_entry{ true }; + bool _first_error{ true }; }; } // namespace framework } // namespace test diff --git a/framework/printers/PrettyPrinter.cpp b/framework/printers/PrettyPrinter.cpp index fd90401693..631d96917a 100644 --- a/framework/printers/PrettyPrinter.cpp +++ b/framework/printers/PrettyPrinter.cpp @@ -88,6 +88,19 @@ void PrettyPrinter::print_test_footer() { } +void PrettyPrinter::print_errors_header() +{ +} + +void PrettyPrinter::print_errors_footer() +{ +} + +void PrettyPrinter::print_error(const std::exception &error) +{ + *_stream << begin_color("1") << error.what() << end_color() << "\n"; +} + void PrettyPrinter::print_measurements(const Profiler::MeasurementsMap &measurements) { for(const auto &instrument : measurements) diff --git a/framework/printers/PrettyPrinter.h b/framework/printers/PrettyPrinter.h index 893b1fadd2..fa7b7b2c59 100644 --- a/framework/printers/PrettyPrinter.h +++ b/framework/printers/PrettyPrinter.h @@ -51,6 +51,9 @@ public: void print_run_footer() override; void print_test_header(const TestInfo &info) override; void print_test_footer() override; + void print_errors_header() override; + void print_errors_footer() override; + void print_error(const std::exception &error) override; void print_measurements(const Profiler::MeasurementsMap &measurements) override; private: diff --git a/framework/printers/Printer.h b/framework/printers/Printer.h index 7d8af12416..85b7a570c8 100644 --- a/framework/printers/Printer.h +++ b/framework/printers/Printer.h @@ -29,6 +29,7 @@ #include <fstream> #include <iostream> #include <ostream> +#include <stdexcept> namespace arm_compute { @@ -95,6 +96,18 @@ public: /** Print footer after a test. */ virtual void print_test_footer() = 0; + /** Print header before errors. */ + virtual void print_errors_header() = 0; + + /** Print footer after errors. */ + virtual void print_errors_footer() = 0; + + /** Print test error. + * + * @param[in] error Description of the error. + */ + virtual void print_error(const std::exception &error) = 0; + /** Print measurements for a test. * * @param[in] measurements Measurements as collected by a @ref Profiler. |