• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

randombit / botan / 5230455705

10 Jun 2023 02:30PM UTC coverage: 91.715% (-0.03%) from 91.746%
5230455705

push

github

randombit
Merge GH #3584 Change clang-format AllowShortFunctionsOnASingleLine config from All to Inline

77182 of 84154 relevant lines covered (91.72%)

11975295.43 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

77.36
/src/tests/runner/test_stdout_reporter.cpp
1
/*
2
* (C) 2022 Jack Lloyd
3
* (C) 2022 René Meusel, Rohde & Schwarz Cybersecurity
4
*
5
* Botan is released under the Simplified BSD License (see license.txt)
6
*/
7

8
#include "test_stdout_reporter.h"
9

10
#include <botan/version.h>
11

12
namespace Botan_Tests {
13

14
StdoutReporter::StdoutReporter(const Test_Options& opts, std::ostream& output_stream) :
15
      Reporter(opts), m_verbose(opts.verbose()), m_out(output_stream), m_tests_failed(0), m_tests_run(0) {}
16

17
void StdoutReporter::next_run() {
18
   if(current_test_run() == 1) {
19
      render_preamble();
20
   }
21
   clear();
22
}
23

24
void StdoutReporter::next_testsuite(const std::string& name) {
25
   m_out << name << ":\n";
26
}
27

28
void StdoutReporter::record(const std::string& name, const Test::Result& result) {
29
   m_out << result.result_string();
30
   m_out << std::flush;
31
   m_tests_run += result.tests_run();
32

33
   const size_t failed = result.tests_failed();
34
   if(failed > 0) {
35
      m_tests_failed += failed;
36
      m_tests_failed_names.insert(name);
37
   }
38
}
39

40
void StdoutReporter::render() const {
41
   render_summary();
42
}
43

44
void StdoutReporter::clear() {
45
   m_tests_failed_names.clear();
46
   m_tests_failed = 0;
47
   m_tests_run = 0;
48
}
49

50
void StdoutReporter::render_preamble() const {
51
   m_out << "Testing " << Botan::version_string() << "\n";
52

53
   if(!properties().empty()) {
54
      m_out << "Properties:\n";
55

56
      for(const auto& prop : properties()) {
57
         m_out << "  " << prop.first << ": " << prop.second << "\n";
58
      }
59
   }
60
}
61

62
void StdoutReporter::render_summary() const {
63
   const auto total_ns = elapsed_time();
64

65
   if(total_test_runs() == 1) {
66
      m_out << "Tests";
67
   } else {
68
      m_out << "Test run " << current_test_run() << "/" << total_test_runs();
69
   }
70

71
   m_out << " complete ran " << m_tests_run << " tests in " << Botan_Tests::Test::format_time(total_ns) << " ";
72

73
   if(m_tests_failed > 0) {
74
      m_out << m_tests_failed << " tests failed (in ";
75

76
      bool first = true;
77
      for(const auto& test : m_tests_failed_names) {
78
         if(!first) {
79
            m_out << " ";
80
         }
81
         first = false;
82
         m_out << test;
83
      }
84

85
      m_out << ")";
86
   } else if(m_tests_run > 0) {
87
      m_out << "all tests ok";
88
   }
89

90
   m_out << "\n";
91
}
92

93
}  // namespace Botan_Tests
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc