"[%s%s%s] %s[elapsed: %0.3fms, expected < %0.3fms]%s\n", BOLD_GREEN_BEGIN, \
" OK ", BOLD_GREEN_END, BOLD_RED_BEGIN, elapsed, max, BOLD_RED_END
+extern const std::string COLLECTOR_NO_VERBOSE_HELP;
+
// Get duration as a fraction of millisecond (max precision is 1 microsecond)
double get_milliseconds (const std::chrono::system_clock::duration& performanceTime);
std::string CollectorFileHelp(const std::string &defaultFilename);
bool ParseCollectorFileArg(const std::string &arg, std::string &filename);
+bool ParseCollectorNoVerboseArg(const std::string &arg, bool &verbosity);
} // namespace Test
} // namespace DPL
= std::chrono::microseconds::zero());
virtual void Finish();
- void PrintfErrorMessage(const char* type,
- const std::string& message,
- bool verbosity);
- void PrintfIgnoredMessage(const char* type,
- const std::string& message,
- bool verbosity);
+ void PrintfErrorMessage(const char* type, const std::string& message);
+ void PrintfIgnoredMessage(const char* type, const std::string& message);
void PrintStats(const std::string& name, const Statistic& stats);
std::string m_filename;
Statistic m_stats;
std::string m_currentGroup;
std::map<std::string, Statistic> m_groupsStats;
+ bool m_verbosity;
};
} // namespace Test
namespace DPL {
namespace Test {
+namespace {
+
+const std::string NO_VERBOSE_ARG = "--no-verbose";
+
+} // namespace
+
+const std::string COLLECTOR_NO_VERBOSE_HELP =
+ NO_VERBOSE_ARG + " - turns off verbosity\n" +
+ std::string(NO_VERBOSE_ARG.size(), ' ') + " verbosity turned on by default\n";
+
double get_milliseconds (const std::chrono::system_clock::duration& performanceTime)
{
return (static_cast<double>(std::chrono::duration_cast<std::chrono::microseconds>
return false;
}
+bool ParseCollectorNoVerboseArg(const std::string &arg, bool &verbosity)
+{
+ if (arg != NO_VERBOSE_ARG)
+ return false;
+ verbosity=false;
+ return true;
+}
+
} // namespace Test
} // namespace DPL
namespace DPL {
namespace Test {
-namespace {
-
-const std::string NO_VERBOSE_ARG = "--no-verbose";
-
-}
ConsoleCollector::ConsoleCollector()
: m_verbosity(true)
bool ConsoleCollector::ParseCollectorSpecificArg(const std::string& arg)
{
- if (arg != NO_VERBOSE_ARG)
- return false;
- m_verbosity=false;
- return true;
+ return ParseCollectorNoVerboseArg(arg, m_verbosity);
}
std::string ConsoleCollector::CollectorSpecificHelp() const
{
- return NO_VERBOSE_ARG + " - turns off verbosity\n" +
- std::string(NO_VERBOSE_ARG.size(), ' ') + " verbosity turned on by default\n";
+ return COLLECTOR_NO_VERBOSE_HELP;
}
void ConsoleCollector::CollectCurrentTestGroupName(const std::string& name)
}
HtmlCollector::HtmlCollector()
- : m_filename(DEFAULT_HTML_FILE_NAME)
+ : m_filename(DEFAULT_HTML_FILE_NAME),
+ m_verbosity(true)
{
}
std::string HtmlCollector::CollectorSpecificHelp() const
{
- return CollectorFileHelp(DEFAULT_HTML_FILE_NAME);
+ return CollectorFileHelp(DEFAULT_HTML_FILE_NAME) + COLLECTOR_NO_VERBOSE_HELP;
}
void HtmlCollector::Start()
bool HtmlCollector::ParseCollectorSpecificArg(const std::string& arg)
{
- return ParseCollectorFileArg(arg, m_filename);
+ return ParseCollectorFileArg(arg, m_filename) || ParseCollectorNoVerboseArg(arg, m_verbosity);
}
void HtmlCollector::CollectResult(const std::string& id,
fprintf(m_fp.Get(), GREEN_RESULT_OK);
break;
case FailStatus::FAILED:
- PrintfErrorMessage(" FAILED ", reason, true);
+ PrintfErrorMessage(" FAILED ", reason);
break;
case FailStatus::IGNORED:
- PrintfIgnoredMessage("Ignored ", reason, true);
+ PrintfIgnoredMessage("Ignored ", reason);
break;
default:
Assert(false && "Bad status");
m_stats.AddTest(status);
}
-void HtmlCollector::PrintfErrorMessage(const char* type,
- const std::string& message,
- bool verbosity)
+void HtmlCollector::PrintfErrorMessage(const char* type, const std::string& message)
{
using namespace DPL::Colors::Html;
- if (verbosity) {
+ fprintf(m_fp.Get(),
+ "[%s%s%s]",
+ BOLD_RED_BEGIN,
+ type,
+ BOLD_RED_END);
+ if (m_verbosity) {
fprintf(m_fp.Get(),
- "[%s%s%s] %s%s%s\n",
- BOLD_RED_BEGIN,
- type,
- BOLD_RED_END,
+ " %s%s%s",
BOLD_YELLOW_BEGIN,
message.c_str(),
BOLD_YELLOW_END);
- } else {
- fprintf(m_fp.Get(),
- "[%s%s%s]\n",
- BOLD_RED_BEGIN,
- type,
- BOLD_RED_END);
}
+ fprintf(m_fp.Get(), "\n");
}
-void HtmlCollector::PrintfIgnoredMessage(const char* type,
- const std::string& message,
- bool verbosity)
+void HtmlCollector::PrintfIgnoredMessage(const char* type, const std::string& message)
{
using namespace DPL::Colors::Html;
- if (verbosity) {
+ fprintf(m_fp.Get(),
+ "[%s%s%s]",
+ CYAN_BEGIN,
+ type,
+ CYAN_END);
+ if (m_verbosity) {
fprintf(m_fp.Get(),
- "[%s%s%s] %s%s%s\n",
- CYAN_BEGIN,
- type,
- CYAN_END,
+ " %s%s%s",
BOLD_GOLD_BEGIN,
message.c_str(),
BOLD_GOLD_END);
- } else {
- fprintf(m_fp.Get(),
- "[%s%s%s]\n",
- CYAN_BEGIN,
- type,
- CYAN_END);
}
+ fprintf(m_fp.Get(), "\n");
}
void HtmlCollector::PrintStats(const std::string& name, const Statistic& stats)