Add --no-verbose option to HTML collector 52/29052/15
authorMarcin Niesluchowski <m.niesluchow@samsung.com>
Thu, 16 Oct 2014 12:17:36 +0000 (14:17 +0200)
committerRadoslaw Bartosiak <r.bartosiak@samsung.com>
Wed, 11 Mar 2015 12:59:14 +0000 (13:59 +0100)
With --no-verbose param fail/ignore reason is not displayed

Change-Id: I790d24f2db8b707df20f88e0df08ec20cf5eab03

src/framework/include/dpl/test/test_results_collector_commons.h
src/framework/include/dpl/test/test_results_collector_html.h
src/framework/src/test_results_collector_commons.cpp
src/framework/src/test_results_collector_console.cpp
src/framework/src/test_results_collector_html.cpp

index 606f8c3..8fc98c1 100644 (file)
@@ -41,11 +41,14 @@ namespace Test {
     "[%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
index 90d635e..6d8eafc 100644 (file)
@@ -56,12 +56,8 @@ private:
                                    = 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;
@@ -69,6 +65,7 @@ private:
     Statistic m_stats;
     std::string m_currentGroup;
     std::map<std::string, Statistic> m_groupsStats;
+    bool m_verbosity;
 };
 
 } // namespace Test
index 701fd36..013bde2 100644 (file)
 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>
@@ -49,6 +59,14 @@ bool ParseCollectorFileArg(const std::string &arg, std::string &filename)
     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
 
index d60afa5..9ad0c04 100644 (file)
 
 namespace DPL {
 namespace Test {
-namespace {
-
-const std::string NO_VERBOSE_ARG = "--no-verbose";
-
-}
 
 ConsoleCollector::ConsoleCollector()
     : m_verbosity(true)
@@ -50,16 +45,12 @@ TestResultsCollectorBase* ConsoleCollector::Constructor()
 
 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)
index 0ca0475..ee76c49 100644 (file)
@@ -39,7 +39,8 @@ const char *DEFAULT_HTML_FILE_NAME = "index.html";
 }
 
 HtmlCollector::HtmlCollector()
-    : m_filename(DEFAULT_HTML_FILE_NAME)
+    : m_filename(DEFAULT_HTML_FILE_NAME),
+      m_verbosity(true)
 {
 }
 
@@ -66,7 +67,7 @@ bool HtmlCollector::Configure()
 
 std::string HtmlCollector::CollectorSpecificHelp() const
 {
-    return CollectorFileHelp(DEFAULT_HTML_FILE_NAME);
+    return CollectorFileHelp(DEFAULT_HTML_FILE_NAME) + COLLECTOR_NO_VERBOSE_HELP;
 }
 
 void HtmlCollector::Start()
@@ -101,7 +102,7 @@ void HtmlCollector::Finish()
 
 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,
@@ -137,10 +138,10 @@ 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");
@@ -149,51 +150,41 @@ void HtmlCollector::CollectResult(const std::string& id,
     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)