diff options
author | Manoj Srivastava <srivasta@debian.org> | 2020-05-22 19:57:41 -0700 |
---|---|---|
committer | Manoj Srivastava <srivasta@debian.org> | 2020-05-22 20:02:19 -0700 |
commit | c3d2579ad8d7eb33059aa8fdbaf5b564411a57f2 (patch) | |
tree | 1570cda0676fdcf4171a69a7fe313c1b89a52b0c /vendor/bandit/bandit/reporters/test_run_summary.h | |
parent | 986b7742bf244b4073ecca0723615f70be8a1ab6 (diff) | |
parent | 4e9b9c402ed95bf9a17fd6d795bc49bb4128a6fa (diff) |
Merge branch 'upstream' into debian-cmake-fixes
Diffstat (limited to 'vendor/bandit/bandit/reporters/test_run_summary.h')
-rw-r--r-- | vendor/bandit/bandit/reporters/test_run_summary.h | 90 |
1 files changed, 90 insertions, 0 deletions
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 |