summaryrefslogtreecommitdiff
path: root/vendor/bandit/bandit/reporters
diff options
context:
space:
mode:
authorManoj Srivastava <srivasta@debian.org>2020-05-22 19:57:41 -0700
committerManoj Srivastava <srivasta@debian.org>2020-05-22 20:02:19 -0700
commitc3d2579ad8d7eb33059aa8fdbaf5b564411a57f2 (patch)
tree1570cda0676fdcf4171a69a7fe313c1b89a52b0c /vendor/bandit/bandit/reporters
parent986b7742bf244b4073ecca0723615f70be8a1ab6 (diff)
parent4e9b9c402ed95bf9a17fd6d795bc49bb4128a6fa (diff)
Merge branch 'upstream' into debian-cmake-fixes
Diffstat (limited to 'vendor/bandit/bandit/reporters')
-rw-r--r--vendor/bandit/bandit/reporters/colorizer.h141
-rw-r--r--vendor/bandit/bandit/reporters/dots_reporter.h69
-rw-r--r--vendor/bandit/bandit/reporters/info_reporter.h194
-rw-r--r--vendor/bandit/bandit/reporters/progress_reporter.h116
-rw-r--r--vendor/bandit/bandit/reporters/reporters.h29
-rw-r--r--vendor/bandit/bandit/reporters/single_line_reporter.h86
-rw-r--r--vendor/bandit/bandit/reporters/spec_reporter.h126
-rw-r--r--vendor/bandit/bandit/reporters/test_run_summary.h90
-rw-r--r--vendor/bandit/bandit/reporters/xunit_reporter.h109
9 files changed, 960 insertions, 0 deletions
diff --git a/vendor/bandit/bandit/reporters/colorizer.h b/vendor/bandit/bandit/reporters/colorizer.h
new file mode 100644
index 00000000..e8979eec
--- /dev/null
+++ b/vendor/bandit/bandit/reporters/colorizer.h
@@ -0,0 +1,141 @@
+#ifndef BANDIT_REPORTERS_COLORIZER_H
+#define BANDIT_REPORTERS_COLORIZER_H
+
+#ifdef _WIN32
+ #ifndef NOMINMAX
+ #define NOMINMAX
+ #endif
+
+ #define WIN32_LEAN_AND_MEAN
+ #include <windows.h>
+#endif
+
+namespace bandit { namespace detail {
+
+#ifdef _WIN32
+ struct colorizer
+ {
+ colorizer(bool colors_enabled = true)
+ : colors_enabled_(colors_enabled),
+ stdout_handle_(GetStdHandle(STD_OUTPUT_HANDLE))
+ {
+ original_color_ = get_console_color();
+ }
+
+ const char* green() const
+ {
+ if(colors_enabled_)
+ {
+ set_console_color(FOREGROUND_GREEN);
+ }
+ return "";
+ }
+
+ const char* yellow() const
+ {
+ if(colors_enabled_)
+ {
+ set_console_color(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY);
+ }
+ return "";
+ }
+
+ const char* blue() const
+ {
+ if(colors_enabled_)
+ {
+ set_console_color(FOREGROUND_BLUE);
+ }
+ return "";
+ }
+
+ const char* red() const
+ {
+ if(colors_enabled_)
+ {
+ set_console_color(FOREGROUND_RED);
+ }
+ return "";
+ }
+
+ const char* white() const
+ {
+ if(colors_enabled_)
+ {
+ set_console_color(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY);
+ }
+ return "";
+ }
+
+ const char* reset() const
+ {
+ if(colors_enabled_)
+ {
+ set_console_color(original_color_);
+ }
+ return "";
+ }
+
+ private:
+ WORD get_console_color() const
+ {
+ CONSOLE_SCREEN_BUFFER_INFO info{};
+ GetConsoleScreenBufferInfo(stdout_handle_, &info);
+ return info.wAttributes;
+ }
+
+ void set_console_color(WORD color) const
+ {
+ SetConsoleTextAttribute(stdout_handle_, color);
+ }
+
+ private:
+ bool colors_enabled_;
+ HANDLE stdout_handle_;
+ WORD original_color_;
+ };
+
+#else
+ struct colorizer
+ {
+ colorizer(bool colors_enabled = true)
+ : colors_enabled_(colors_enabled)
+ {}
+
+ const char* green() const
+ {
+ return colors_enabled_ ? "\033[1;32m" : "";
+ }
+
+ const char* yellow() const
+ {
+ return colors_enabled_ ? "\033[1;33m" : "";
+ }
+
+ const char* blue() const
+ {
+ return colors_enabled_ ? "\033[1;34m" : "";
+ }
+
+ const char* red() const
+ {
+ return colors_enabled_ ? "\033[1;31m" : "";
+ }
+
+ const char* white() const
+ {
+ return colors_enabled_ ? "\033[1;37m" : "";
+ }
+
+ const char* reset() const
+ {
+ return colors_enabled_ ? "\033[0m" : "";
+ }
+
+ private:
+ bool colors_enabled_;
+ };
+#endif
+}}
+
+#endif
diff --git a/vendor/bandit/bandit/reporters/dots_reporter.h b/vendor/bandit/bandit/reporters/dots_reporter.h
new file mode 100644
index 00000000..3c5083fe
--- /dev/null
+++ b/vendor/bandit/bandit/reporters/dots_reporter.h
@@ -0,0 +1,69 @@
+#ifndef BANDIT_DOTS_REPORTER_H
+#define BANDIT_DOTS_REPORTER_H
+
+namespace bandit { namespace detail {
+
+ struct dots_reporter : public progress_reporter
+ {
+ dots_reporter(std::ostream& stm, const failure_formatter& failure_formatter,
+ const detail::colorizer& colorizer)
+ : progress_reporter(failure_formatter), stm_(stm), colorizer_(colorizer)
+ {}
+
+ dots_reporter(const failure_formatter& failure_formatter, const detail::colorizer& colorizer)
+ : progress_reporter(failure_formatter), stm_(std::cout), colorizer_(colorizer)
+ {}
+
+ dots_reporter& operator=(const dots_reporter&) { return *this; }
+
+ void test_run_complete()
+ {
+ progress_reporter::test_run_complete();
+
+ stm_ << std::endl;
+
+ test_run_summary summary(specs_run_, specs_failed_, specs_succeeded_, specs_skipped_, failures_,
+ test_run_errors_, colorizer_);
+ summary.write(stm_);
+ stm_.flush();
+ }
+
+ void test_run_error(const char* desc, const struct test_run_error& err)
+ {
+ progress_reporter::test_run_error(desc, err);
+
+ std::stringstream ss;
+ ss << std::endl;
+ ss << "Failed to run \"" << current_context_name() << "\": error \"" << err.what() << "\"" << std::endl;
+
+ test_run_errors_.push_back(ss.str());
+ }
+
+ void it_succeeded(const char* desc)
+ {
+ progress_reporter::it_succeeded(desc);
+ stm_ << colorizer_.green() << "." << colorizer_.reset();
+ stm_.flush();
+ }
+
+ void it_failed(const char* desc, const assertion_exception& ex)
+ {
+ progress_reporter::it_failed(desc, ex);
+ stm_ << colorizer_.red() << "F" << colorizer_.reset();
+ stm_.flush();
+ }
+
+ void it_unknown_error(const char* desc)
+ {
+ progress_reporter::it_unknown_error(desc);
+ stm_ << colorizer_.red() << "E" << colorizer_.reset();
+ stm_.flush();
+ }
+
+ private:
+ std::ostream& stm_;
+ const detail::colorizer& colorizer_;
+ };
+}}
+
+#endif
diff --git a/vendor/bandit/bandit/reporters/info_reporter.h b/vendor/bandit/bandit/reporters/info_reporter.h
new file mode 100644
index 00000000..f9b987d0
--- /dev/null
+++ b/vendor/bandit/bandit/reporters/info_reporter.h
@@ -0,0 +1,194 @@
+#ifndef BANDIT_INFO_REPORTER_H
+#define BANDIT_INFO_REPORTER_H
+
+namespace bandit {
+namespace detail {
+
+struct info_reporter : public progress_reporter
+{
+ info_reporter(std::ostream &stm, const failure_formatter &failure_formatter,
+ const detail::colorizer &colorizer)
+ : progress_reporter(failure_formatter)
+ , stm_(stm)
+ , colorizer_(colorizer)
+ , indentation_(0)
+ {}
+
+ info_reporter(const failure_formatter &failure_formatter, const detail::colorizer &colorizer)
+ : progress_reporter(failure_formatter)
+ , stm_(std::cout)
+ , colorizer_(colorizer)
+ , indentation_(0)
+ {}
+
+ info_reporter &operator=(const info_reporter &)
+ {
+ return *this;
+ }
+
+ void summary()
+ {
+ stm_
+ << colorizer_.white()
+ << "Tests run: " << specs_run_
+ << std::endl;
+ if (specs_skipped_ > 0) {
+ stm_
+ << colorizer_.yellow()
+ << "Skipped: " << specs_skipped_
+ << std::endl;
+ }
+ if (specs_succeeded_ > 0) {
+ stm_
+ << colorizer_.green()
+ << "Passed: " << specs_succeeded_
+ << std::endl;
+ }
+ if (specs_failed_ > 0) {
+ stm_
+ << colorizer_.red()
+ << "Failed: " << specs_failed_
+ << std::endl;
+ std::for_each(failures_.begin(), failures_.end(), [&](const std::string &failure) {
+ stm_
+ << colorizer_.white()
+ << " (*) "
+ << colorizer_.red()
+ << failure << std::endl;
+ });
+ }
+ if (test_run_errors_.size() > 0) {
+ stm_
+ << colorizer_.red()
+ << "Errors: " << test_run_errors_.size()
+ << std::endl;
+ std::for_each(test_run_errors_.begin(), test_run_errors_.end(), [&](const std::string &error) {
+ stm_
+ << colorizer_.white()
+ << " (*) "
+ << colorizer_.red()
+ << error << std::endl;
+ });
+ }
+ stm_
+ << colorizer_.reset()
+ << std::endl;
+ }
+
+ void test_run_complete()
+ {
+ progress_reporter::test_run_complete();
+ stm_ << std::endl;
+ summary();
+ stm_.flush();
+ }
+
+ void test_run_error(const char *desc, const struct test_run_error &err)
+ {
+ progress_reporter::test_run_error(desc, err);
+
+ std::stringstream ss;
+ ss << std::endl;
+ ss << "Failed to run \"" << current_context_name() << "\": error \"" << err.what() << "\"" << std::endl;
+
+ test_run_errors_.push_back(ss.str());
+ }
+
+ virtual void context_starting(const char *desc)
+ {
+ progress_reporter::context_starting(desc);
+
+ stm_
+ << indent()
+ << colorizer_.blue()
+ << "begin "
+ << colorizer_.white()
+ << desc
+ << colorizer_.reset()
+ << std::endl;
+ ++indentation_;
+ stm_.flush();
+
+ }
+
+ virtual void context_ended(const char *desc)
+ {
+ progress_reporter::context_ended(desc);
+ --indentation_;
+ stm_
+ << indent()
+ << colorizer_.blue()
+ << "end "
+ << colorizer_.reset()
+ << desc << std::endl;
+ }
+
+ virtual void it_starting(const char *desc)
+ {
+ progress_reporter::it_starting(desc);
+ stm_
+ << indent()
+ << colorizer_.yellow()
+ << "[ TEST ]"
+ << colorizer_.reset()
+ << " it " << desc;
+ ++indentation_;
+ stm_.flush();
+ }
+
+ virtual void it_succeeded(const char *desc)
+ {
+ progress_reporter::it_succeeded(desc);
+ --indentation_;
+ stm_
+ << "\r" << indent()
+ << colorizer_.green()
+ << "[ PASS ]"
+ << colorizer_.reset()
+ << " it " << desc
+ << std::endl;
+ stm_.flush();
+ }
+
+ virtual void it_failed(const char *desc, const assertion_exception &ex)
+ {
+ progress_reporter::it_failed(desc, ex);
+ --indentation_;
+ stm_
+ << "\r" << indent()
+ << colorizer_.red()
+ << "[ FAIL ]"
+ << colorizer_.reset()
+ << " it " << desc
+ << std::endl;
+ stm_.flush();
+ }
+
+ virtual void it_unknown_error(const char *desc)
+ {
+ progress_reporter::it_unknown_error(desc);
+ --indentation_;
+ stm_
+ << "\r" << indent()
+ << colorizer_.red()
+ << "-ERROR->"
+ << colorizer_.reset()
+ << " it " << desc
+ << std::endl;
+ stm_.flush();
+ }
+
+private:
+ std::string indent()
+ {
+ return std::string(2*indentation_, ' ');
+ }
+
+ std::ostream &stm_;
+ const detail::colorizer &colorizer_;
+ int indentation_;
+};
+}
+}
+
+#endif
diff --git a/vendor/bandit/bandit/reporters/progress_reporter.h b/vendor/bandit/bandit/reporters/progress_reporter.h
new file mode 100644
index 00000000..d9dc47bd
--- /dev/null
+++ b/vendor/bandit/bandit/reporters/progress_reporter.h
@@ -0,0 +1,116 @@
+#ifndef BANDIT_PROGRESS_REPORTER_H
+#define BANDIT_PROGRESS_REPORTER_H
+
+namespace bandit { namespace detail {
+
+ struct progress_reporter : public listener
+ {
+ progress_reporter(const detail::failure_formatter& failure_formatter)
+ : specs_run_(0), specs_succeeded_(0), specs_failed_(0), specs_skipped_(0),
+ failure_formatter_(failure_formatter)
+ {}
+
+ progress_reporter& operator=(const progress_reporter&) { return *this; }
+
+ virtual void test_run_starting()
+ {
+ specs_run_ = 0;
+ specs_succeeded_ = 0;
+ specs_failed_ = 0;
+ specs_skipped_ = 0;
+ failures_.clear();
+ contexts_.clear();
+ }
+
+ virtual void test_run_complete()
+ {
+ }
+
+ virtual void context_starting(const char* desc)
+ {
+ contexts_.push_back(std::string(desc));
+ }
+
+ virtual void context_ended(const char*)
+ {
+ contexts_.pop_back();
+ }
+
+ virtual void test_run_error(const char*, const struct test_run_error&)
+ {}
+
+ void it_starting(const char*)
+ {
+ specs_run_++;
+ }
+
+ void it_succeeded(const char*)
+ {
+ specs_succeeded_++;
+ }
+
+ void it_failed(const char* desc, const assertion_exception& ex)
+ {
+ specs_failed_++;
+
+ std::stringstream ss;
+ ss << std::endl;
+ ss << current_context_name() << " " << desc << ":" << std::endl;
+ ss << failure_formatter_.format(ex);
+
+ failures_.push_back(ss.str());
+ }
+
+ void it_unknown_error(const char* desc)
+ {
+ specs_failed_++;
+
+ std::stringstream ss;
+ ss << std::endl;
+ ss << current_context_name() << " " << desc << ":" << std::endl;
+ ss << "Unknown exception";
+ ss << std::endl;
+
+ failures_.push_back(ss.str());
+ }
+
+ void it_skip(const char* /* desc */)
+ {
+ specs_skipped_++;
+ }
+
+ bool did_we_pass() const
+ {
+ return specs_run_ > 0 && specs_failed_ == 0 && test_run_errors_.size() == 0;
+ }
+
+ protected:
+ std::string current_context_name()
+ {
+ std::string name;
+
+ std::for_each(contexts_.begin(), contexts_.end(), [&](const std::string context){
+ if(name.size() > 0)
+ {
+ name += " ";
+ }
+
+ name += context;
+ });
+
+ return name;
+ }
+
+ protected:
+ int specs_run_;
+ int specs_succeeded_;
+ int specs_failed_;
+ int specs_skipped_;
+ const detail::failure_formatter& failure_formatter_;
+ std::list<std::string> contexts_;
+ std::list<std::string> failures_;
+ std::list<std::string> test_run_errors_;
+ };
+}}
+
+#endif
diff --git a/vendor/bandit/bandit/reporters/reporters.h b/vendor/bandit/bandit/reporters/reporters.h
new file mode 100644
index 00000000..12179270
--- /dev/null
+++ b/vendor/bandit/bandit/reporters/reporters.h
@@ -0,0 +1,29 @@
+#ifndef BANDIT_REPORTERS_H
+#define BANDIT_REPORTERS_H
+
+#include <bandit/reporters/colorizer.h>
+#include <bandit/reporters/progress_reporter.h>
+#include <bandit/reporters/test_run_summary.h>
+#include <bandit/reporters/dots_reporter.h>
+#include <bandit/reporters/single_line_reporter.h>
+#include <bandit/reporters/xunit_reporter.h>
+#include <bandit/reporters/info_reporter.h>
+#include <bandit/reporters/spec_reporter.h>
+
+namespace bandit { namespace detail {
+
+ inline listener& registered_listener(listener* reporter = NULL)
+ {
+ static struct listener* reporter_;
+
+ if(reporter)
+ {
+ reporter_ = reporter;
+ }
+
+ return *reporter_;
+ }
+
+}}
+
+#endif
diff --git a/vendor/bandit/bandit/reporters/single_line_reporter.h b/vendor/bandit/bandit/reporters/single_line_reporter.h
new file mode 100644
index 00000000..08d1c08d
--- /dev/null
+++ b/vendor/bandit/bandit/reporters/single_line_reporter.h
@@ -0,0 +1,86 @@
+#ifndef BANDIT_REPORTERS_SINGLE_LINE_REPORTER_H
+#define BANDIT_REPORTERS_SINGLE_LINE_REPORTER_H
+
+namespace bandit { namespace detail {
+
+ struct single_line_reporter : public progress_reporter
+ {
+ single_line_reporter(std::ostream& stm, const failure_formatter& failure_formatter,
+ const detail::colorizer& colorizer)
+ : progress_reporter(failure_formatter), stm_(stm), colorizer_(colorizer)
+ {}
+
+ single_line_reporter(const failure_formatter& failure_formatter,
+ const detail::colorizer& colorizer)
+ : progress_reporter(failure_formatter), stm_(std::cout), colorizer_(colorizer)
+ {}
+
+ single_line_reporter& operator=(const single_line_reporter&) { return *this; }
+
+ void test_run_complete()
+ {
+ progress_reporter::test_run_complete();
+
+ stm_ << std::endl;
+
+ test_run_summary summary(specs_run_, specs_failed_, specs_succeeded_, specs_skipped_, failures_,
+ test_run_errors_, colorizer_);
+ summary.write(stm_);
+ }
+
+ void test_run_error(const char* desc, const struct test_run_error& err)
+ {
+ progress_reporter::test_run_error(desc, err);
+
+ std::stringstream ss;
+ ss << std::endl;
+ ss << "Failed to run \"" << current_context_name() << "\": error \"" << err.what() << "\"" << std::endl;
+
+ test_run_errors_.push_back(ss.str());
+ }
+
+ void it_starting(const char* desc)
+ {
+ print_status_line();
+ progress_reporter::it_starting(desc);
+ }
+
+ void it_succeeded(const char* desc)
+ {
+ progress_reporter::it_succeeded(desc);
+ print_status_line();
+ }
+
+ void it_failed(const char* desc, const assertion_exception& ex)
+ {
+ progress_reporter::it_failed(desc, ex);
+ print_status_line();
+ }
+
+ void it_unknown_error(const char* desc)
+ {
+ progress_reporter::it_unknown_error(desc);
+ print_status_line();
+ }
+
+ private:
+ void print_status_line()
+ {
+ stm_ << '\r';
+ stm_ << "Executed " << specs_run_ << " tests.";
+
+ if(specs_failed_)
+ {
+ stm_ << " " << specs_succeeded_ << " succeeded. " << colorizer_.red() << specs_failed_ <<
+ " failed." << colorizer_.reset();
+ }
+ stm_.flush();
+ }
+
+ private:
+ std::ostream& stm_;
+ const detail::colorizer& colorizer_;
+ };
+}}
+
+#endif
diff --git a/vendor/bandit/bandit/reporters/spec_reporter.h b/vendor/bandit/bandit/reporters/spec_reporter.h
new file mode 100644
index 00000000..6d63bfb0
--- /dev/null
+++ b/vendor/bandit/bandit/reporters/spec_reporter.h
@@ -0,0 +1,126 @@
+#ifndef BANDIT_SPEC_REPORTER_H
+#define BANDIT_SPEC_REPORTER_H
+
+namespace bandit { namespace detail {
+
+ struct spec_reporter : public progress_reporter
+ {
+ spec_reporter(std::ostream& stm, const failure_formatter& failure_formatter,
+ const detail::colorizer& colorizer)
+ : progress_reporter(failure_formatter), stm_(stm), colorizer_(colorizer), indentation_(0)
+ {}
+
+ spec_reporter(const failure_formatter& failure_formatter, const detail::colorizer& colorizer)
+ : progress_reporter(failure_formatter), stm_(std::cout), colorizer_(colorizer), indentation_(0)
+ {}
+
+ spec_reporter& operator=(const spec_reporter&) { return *this; }
+
+ void test_run_complete()
+ {
+ progress_reporter::test_run_complete();
+
+ stm_ << std::endl;
+
+ test_run_summary summary(specs_run_, specs_failed_, specs_succeeded_, specs_skipped_, failures_,
+ test_run_errors_, colorizer_);
+ summary.write(stm_);
+ stm_.flush();
+ }
+
+ void test_run_error(const char* desc, const struct test_run_error& err)
+ {
+ progress_reporter::test_run_error(desc, err);
+
+ std::stringstream ss;
+ ss << std::endl;
+ ss << "Failed to run \"" << current_context_name() << "\": error \"" << err.what() << "\"" << std::endl;
+
+ test_run_errors_.push_back(ss.str());
+ }
+
+ virtual void context_starting(const char* desc)
+ {
+ progress_reporter::context_starting(desc);
+
+ stm_ << indent();
+ stm_ << "describe " << desc << std::endl;
+ increase_indent();
+ stm_.flush();
+
+ }
+
+ virtual void context_ended(const char* desc)
+ {
+ progress_reporter::context_ended(desc);
+ decrease_indent();
+ }
+
+ virtual void it_starting(const char* desc)
+ {
+ progress_reporter::it_starting(desc);
+ stm_ << indent() << "- it " << desc << " ... ";
+ stm_.flush();
+ }
+
+ virtual void it_succeeded(const char* desc)
+ {
+ progress_reporter::it_succeeded(desc);
+ stm_ << colorizer_.green();
+ stm_ << "OK";
+ stm_ << colorizer_.reset();
+ stm_ << std::endl;
+ stm_.flush();
+ }
+
+ virtual void it_failed(const char* desc, const assertion_exception& ex)
+ {
+ progress_reporter::it_failed(desc, ex);
+ stm_ << colorizer_.red();
+ stm_ << "FAILED";
+ stm_ << colorizer_.reset();
+ stm_ << std::endl;
+ stm_.flush();
+ }
+
+ virtual void it_unknown_error(const char* desc)
+ {
+ progress_reporter::it_unknown_error(desc);
+ stm_ << colorizer_.red();
+ stm_ << "ERROR";
+ stm_ << colorizer_.reset();
+ stm_ << std::endl;
+ stm_.flush();
+ }
+
+ virtual void it_skip(const char* desc)
+ {
+ progress_reporter::it_skip(desc);
+ stm_ << indent() << "- it " << desc << " ... SKIPPED" << std::endl;
+ stm_.flush();
+ }
+
+ private:
+ void increase_indent()
+ {
+ indentation_++;
+ }
+
+ void decrease_indent()
+ {
+ indentation_--;
+ }
+
+ std::string indent()
+ {
+ return std::string(indentation_, '\t');
+ }
+
+ private:
+ std::ostream& stm_;
+ const detail::colorizer& colorizer_;
+ int indentation_;
+ };
+}}
+
+#endif
diff --git a/vendor/bandit/bandit/reporters/test_run_summary.h b/vendor/bandit/bandit/reporters/test_run_summary.h
new file mode 100644
index 00000000..aa1d4a59
--- /dev/null
+++ b/vendor/bandit/bandit/reporters/test_run_summary.h
@@ -0,0 +1,90 @@
+#ifndef BANDIT_TEST_RUN_SUMMARY_H
+#define BANDIT_TEST_RUN_SUMMARY_H
+
+namespace bandit { namespace detail {
+
+ struct test_run_summary
+ {
+ test_run_summary(int specs_run, int specs_failed, int specs_succeeded, int specs_skipped,
+ const std::list<std::string>& failures, const std::list<std::string>& test_run_errors,
+ const detail::colorizer& colorizer)
+ : specs_run_(specs_run), specs_succeeded_(specs_succeeded), specs_failed_(specs_failed),
+ specs_skipped_(specs_skipped), failures_(failures), test_run_errors_(test_run_errors),
+ colorizer_(colorizer)
+ {}
+
+ test_run_summary& operator=(const test_run_summary&) { return *this; }
+
+ void write(std::ostream& stm)
+ {
+ if(specs_run_ == 0 && test_run_errors_.size() == 0)
+ {
+ stm << colorizer_.red();
+ stm << "Could not find any tests.";
+ stm << colorizer_.reset();
+ stm << std::endl;
+ return;
+ }
+
+ if(specs_failed_ == 0 && test_run_errors_.size() == 0)
+ {
+ stm << colorizer_.green();
+ stm << "Success!";
+ stm << colorizer_.reset();
+ stm << std::endl;
+ }
+
+ if(test_run_errors_.size() > 0)
+ {
+ std::for_each(test_run_errors_.begin(), test_run_errors_.end(),
+ [&](const std::string& error){
+ stm << error << std::endl;
+ });
+ }
+
+
+ if(specs_failed_ > 0)
+ {
+ stm << colorizer_.red();
+ stm << "There were failures!";
+ stm << colorizer_.reset() << std::endl;
+ std::for_each(failures_.begin(), failures_.end(),
+ [&](const std::string& failure) {
+ stm << failure << std::endl;
+ });
+ stm << std::endl;
+ }
+
+ stm << "Test run complete. " << specs_run_ << " tests run. " << specs_succeeded_ <<
+ " succeeded.";
+
+ if(specs_skipped_ > 0)
+ {
+ stm << " " << specs_skipped_ << " skipped.";
+ }
+
+ if(specs_failed_ > 0)
+ {
+ stm << " " << specs_failed_ << " failed.";
+ }
+
+ if(test_run_errors_.size() > 0)
+ {
+ stm << " " << test_run_errors_.size() << " test run errors.";
+ }
+
+ stm << std::endl;
+ }
+
+ private:
+ int specs_run_;
+ int specs_succeeded_;
+ int specs_failed_;
+ int specs_skipped_;
+ std::list<std::string> failures_;
+ std::list<std::string> test_run_errors_;
+ const detail::colorizer& colorizer_;
+ };
+}}
+
+#endif
diff --git a/vendor/bandit/bandit/reporters/xunit_reporter.h b/vendor/bandit/bandit/reporters/xunit_reporter.h
new file mode 100644
index 00000000..15f6ea29
--- /dev/null
+++ b/vendor/bandit/bandit/reporters/xunit_reporter.h
@@ -0,0 +1,109 @@
+#ifndef BANDIT_REPORTERS_XUNIT_REPORTER_H
+#define BANDIT_REPORTERS_XUNIT_REPORTER_H
+
+namespace bandit { namespace detail {
+
+ struct xunit_reporter : public progress_reporter
+ {
+ xunit_reporter(std::ostream& stm, const failure_formatter& formatter)
+ : progress_reporter(formatter), stm_(stm)
+ {
+ }
+
+ xunit_reporter(const failure_formatter& formatter)
+ : progress_reporter(formatter), stm_(std::cout)
+ {
+ }
+
+ void it_starting(const char* desc)
+ {
+ progress_reporter::it_starting(desc);
+ work_stm_ << "\t<testcase classname=\"" << escape(current_context_name()) << "\" ";
+ work_stm_ << "name=\"" << escape(desc) << "\" time=\"0\">\n";
+ }
+
+ void it_succeeded(const char* desc)
+ {
+ progress_reporter::it_succeeded(desc);
+ work_stm_ << "\t</testcase>\n";
+ }
+
+ void it_failed(const char* desc, const assertion_exception& ex)
+ {
+ progress_reporter::it_failed(desc, ex);
+ work_stm_ << "\t\t<failure message=\"" << escape(failure_formatter_.format(ex)) << "\" />\n";
+ work_stm_ << "\t</testcase>\n";
+ }
+
+ void it_unknown_error(const char* desc)
+ {
+ progress_reporter::it_unknown_error(desc);
+ work_stm_ << "\t\t<failure message=\"Unknown exception\" />\n";
+ work_stm_ << "\t</testcase>\n";
+ }
+
+ void it_skip(const char* desc)
+ {
+ progress_reporter::it_skip(desc);
+ work_stm_ << "\t<testcase classname=\"" << escape(current_context_name()) << "\" ";
+ work_stm_ << "name=\"" << escape(desc) << "\" time=\"0\">\n";
+ work_stm_ << "\t\t<skipped />\n";
+ work_stm_ << "\t</testcase>\n";
+ }
+
+ void test_run_complete()
+ {
+ stm_ << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
+ stm_ << "<testsuite name=\"bandit\" tests=\"" << specs_run_ << "\" errors=\"0\" failures=\""
+ << specs_failed_ << "\"";
+
+ if(specs_skipped_ > 0)
+ {
+ stm_ << " skipped=\"" << specs_skipped_ << "\"";
+ }
+
+ stm_ << ">\n";
+
+ stm_ << work_stm_.str();
+
+ stm_ << "</testsuite>\n";
+ }
+
+ private:
+ std::string escape(const std::string& str)
+ {
+ std::stringstream stm;
+
+ std::for_each(str.begin(), str.end(), [&](char c){
+ switch(c)
+ {
+ case '&':
+ stm << "&amp;";
+ break;
+ case '<':
+ stm << "&lt;";
+ break;
+ case '>':
+ stm << "&gt;";
+ break;
+ case '\\':
+ stm << "&apos;";
+ break;
+ case '\"':
+ stm << "&quot;";
+ break;
+ default:
+ stm << c;
+ }
+ });
+
+ return stm.str();
+ }
+
+ private:
+ std::ostream& stm_;
+ std::stringstream work_stm_;
+ };
+}}
+
+#endif