On 07/02/2014 09:24 AM, Brad King wrote:
> On 07/02/2014 08:13 AM, Ben Boeckel wrote:
>> Colors should only be output if we're outputting to a TTY. Pipes or
>> redirections should not be colored (they'll only confuse those who don't
>> recognize the escape sequences). CMake also has color routines already,
>> but I don't know off-hand how accessible they are from CTest code (i.e.,
>> might be static functions).
> 
> Look for uses of "cmsysTerminal_cfprintf" as an example.
> See its declaration in "Source/kwsys/Terminal.h.in" also.

I've attached an implementation that uses cmsysTerminal_cfprintf.

Is it acceptable to decouple outputting this line from cmCTest::Log? Currently
cmCTestLog is a macro that uses cmCTest::Log, which uses C++ ostreams.

Would it be better to move the color logic and manipulation to something shared
between Log and cmsysTerminal_cfprintf, and add a Log that can use color?

Is it preferable to keep the user-facing string on one line, or break it up for
line length?

===========================================================



DISCLAIMER:
This e-mail and any attachments to it contain confidential and proprietary 
material of Barracuda, its affiliates or agents, and is solely for the use of 
the intended recipient. Any review, use, disclosure, distribution or copying of 
this transmittal is prohibited except by or on behalf of the intended 
recipient. If you have received this transmittal in error, please notify the 
sender and destroy this e-mail and any attachments and all copies, whether 
electronic or printed.

>From d699f93580ae19ad7b0dd2fe52071f0c222d48c7 Mon Sep 17 00:00:00 2001
From: Steve Dougherty <sdoughe...@barracuda.com>
Date: Wed, 9 Jul 2014 16:23:45 -0400
Subject: [PATCH 1/2] color test summary output

---
 Source/CTest/cmCTestTestHandler.cxx | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx
index f21d166..f1836fa 100644
--- a/Source/CTest/cmCTestTestHandler.cxx
+++ b/Source/CTest/cmCTestTestHandler.cxx
@@ -22,6 +22,7 @@
 #include <cmsys/Base64.h>
 #include <cmsys/Directory.hxx>
 #include <cmsys/FStream.hxx>
+#include <cmsys/Terminal.h>
 #include "cmMakefile.h"
 #include "cmGlobalGenerator.h"
 #include "cmLocalGenerator.h"
@@ -583,10 +584,18 @@ int cmCTestTestHandler::ProcessHandler()
       percent = 99;
       }
 
-    cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl
-               << static_cast<int>(percent + .5) << "% tests passed, "
-               << failed.size() << " tests failed out of "
-               << total << std::endl);
+    int color;
+    if ( failed.size() )
+      {
+        color = cmsysTerminal_Color_ForegroundRed;
+      }
+    else
+      {
+        color = cmsysTerminal_Color_ForegroundGreen;
+      }
+    cmsysTerminal_cfprintf(color, stdout, "\n%d%% tests passed, %d tests failed out of %d\n",
+               static_cast<int>(percent + .5), failed.size(), total);
+
     if(this->CTest->GetLabelSummary())
       {
       this->PrintLabelSummary();
-- 
2.0.1

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers

Reply via email to