Add --no-verbose option to Console collector
[platform/core/test/security-tests.git] / src / framework / src / test_results_collector_console.cpp
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)