Add --no-verbose option to Console collector 53/29053/13
authorMarcin Niesluchowski <m.niesluchow@samsung.com>
Thu, 16 Oct 2014 12:21:58 +0000 (14:21 +0200)
committerZbigniew Jasinski <z.jasinski@samsung.com>
Tue, 10 Mar 2015 16:11:12 +0000 (17:11 +0100)
With --no-verbose param fail/ignore reason is not displayed

Change-Id: Id2d0b93424f0ece32cad90d23b815146f4c6d111

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

index 332763b..4fbe00f 100644 (file)
@@ -40,6 +40,8 @@ public:
 private:
     ConsoleCollector();
 
+    virtual bool ParseCollectorSpecificArg(const std::string& arg);
+    virtual std::string CollectorSpecificHelp() const;
     virtual void CollectCurrentTestGroupName(const std::string& name);
     virtual void CollectResult(const std::string& id,
                                const FailStatus status = FailStatus::NONE,
@@ -51,17 +53,14 @@ 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& title, const Statistic& stats);
 
     Statistic m_stats;
     std::map<std::string, Statistic> m_groupsStats;
     std::string m_currentGroup;
+    bool m_verbosity;
 };
 
 } // namespace Test
index 09030a8..d60afa5 100644 (file)
 
 namespace DPL {
 namespace Test {
+namespace {
+
+const std::string NO_VERBOSE_ARG = "--no-verbose";
+
+}
 
 ConsoleCollector::ConsoleCollector()
+    : m_verbosity(true)
 {
 }
 
@@ -42,6 +48,20 @@ TestResultsCollectorBase* ConsoleCollector::Constructor()
     return new ConsoleCollector();
 }
 
+bool ConsoleCollector::ParseCollectorSpecificArg(const std::string& arg)
+{
+    if (arg != NO_VERBOSE_ARG)
+        return false;
+    m_verbosity=false;
+    return true;
+}
+
+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";
+}
+
 void ConsoleCollector::CollectCurrentTestGroupName(const std::string& name)
 {
     printf("Starting group %s\n", name.c_str());
@@ -93,10 +113,10 @@ void ConsoleCollector::CollectResult(const std::string& id,
         printf(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");
@@ -105,46 +125,36 @@ void ConsoleCollector::CollectResult(const std::string& id,
     m_groupsStats[m_currentGroup].AddTest(status);
 }
 
-void ConsoleCollector::PrintfErrorMessage(const char* type,
-                                          const std::string& message,
-                                          bool verbosity)
+void ConsoleCollector::PrintfErrorMessage(const char* type, const std::string& message)
 {
     using namespace DPL::Colors::Text;
-    if (verbosity) {
-        printf("[%s%s%s] %s%s%s\n",
-               BOLD_RED_BEGIN,
-               type,
-               BOLD_RED_END,
+    printf("[%s%s%s]",
+           BOLD_RED_BEGIN,
+           type,
+           BOLD_RED_END);
+    if (m_verbosity) {
+        printf(" %s%s%s",
                BOLD_YELLOW_BEGIN,
                message.c_str(),
                BOLD_YELLOW_END);
-    } else {
-        printf("[%s%s%s]\n",
-               BOLD_RED_BEGIN,
-               type,
-               BOLD_RED_END);
     }
+    printf("\n");
 }
 
-void ConsoleCollector::PrintfIgnoredMessage(const char* type,
-                                            const std::string& message,
-                                            bool verbosity)
+void ConsoleCollector::PrintfIgnoredMessage(const char* type, const std::string& message)
 {
     using namespace DPL::Colors::Text;
-    if (verbosity) {
-        printf("[%s%s%s] %s%s%s\n",
-               CYAN_BEGIN,
-               type,
-               CYAN_END,
+    printf("[%s%s%s]",
+           CYAN_BEGIN,
+           type,
+           CYAN_END);
+    if (m_verbosity) {
+        printf(" %s%s%s",
                BOLD_GOLD_BEGIN,
                message.c_str(),
                BOLD_GOLD_END);
-    } else {
-        printf("[%s%s%s]\n",
-               CYAN_BEGIN,
-               type,
-               CYAN_END);
     }
+    printf("\n");
 }
 
 void ConsoleCollector::PrintStats(const std::string& title, const Statistic& stats)