summaryrefslogtreecommitdiffstats
path: root/Source/cmCTest.cxx
diff options
context:
space:
mode:
authorSylvain Joubert <joubert.sy@gmail.com>2018-11-07 15:33:28 (GMT)
committerSylvain Joubert <joubert.sy@gmail.com>2018-11-09 17:57:41 (GMT)
commitffdec37a197499929e2cbc4fa825f5bf9b7d0f26 (patch)
treef4edf6259f1f08fdd64849e8cdae50909c7a7cf0 /Source/cmCTest.cxx
parent48bc74710d4ddcf62e3dcf69e3400e4060a2bdc1 (diff)
downloadCMake-ffdec37a197499929e2cbc4fa825f5bf9b7d0f26.zip
CMake-ffdec37a197499929e2cbc4fa825f5bf9b7d0f26.tar.gz
CMake-ffdec37a197499929e2cbc4fa825f5bf9b7d0f26.tar.bz2
CTest: Add colored output on tests summary where supported
- Number of passed/failed tests is colored according to the whole outcome - Individual listed tested are colored according to their completion status: * Disabled: blue * Failed: red * Not Run: yellow
Diffstat (limited to 'Source/cmCTest.cxx')
-rw-r--r--Source/cmCTest.cxx43
1 files changed, 38 insertions, 5 deletions
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index 9a046db..c2b6575 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -296,6 +296,7 @@ cmCTest::cmCTest()
this->DropSiteCDash = false;
this->BuildID = "";
this->OutputTestOutputOnTestFailure = false;
+ this->OutputColorCode = this->ColoredOutputSupportedByConsole();
this->RepeatTests = 1; // default to run each test once
this->RepeatUntilFail = false;
@@ -2075,7 +2076,18 @@ bool cmCTest::HandleCommandLineArguments(size_t& i,
return true;
}
-bool cmCTest::ProgressOutputSupportedByConsole() const
+#if !defined(_WIN32)
+bool cmCTest::ConsoleIsNotDumb()
+{
+ std::string term_env_variable;
+ if (cmSystemTools::GetEnv("TERM", term_env_variable)) {
+ return isatty(1) && term_env_variable != "dumb";
+ }
+ return false;
+}
+#endif
+
+bool cmCTest::ProgressOutputSupportedByConsole()
{
#if defined(_WIN32)
// On Windows we need a console buffer.
@@ -2084,12 +2096,19 @@ bool cmCTest::ProgressOutputSupportedByConsole() const
return GetConsoleScreenBufferInfo(console, &csbi);
#else
// On UNIX we need a non-dumb tty.
- std::string term_env_variable;
- if (cmSystemTools::GetEnv("TERM", term_env_variable)) {
- return isatty(1) && term_env_variable != "dumb";
- }
+ return ConsoleIsNotDumb();
#endif
+}
+
+bool cmCTest::ColoredOutputSupportedByConsole()
+{
+#if defined(_WIN32)
+ // Not supported on Windows
return false;
+#else
+ // On UNIX we need a non-dumb tty.
+ return ConsoleIsNotDumb();
+#endif
}
// handle the -S -SR and -SP arguments
@@ -2958,6 +2977,20 @@ void cmCTest::Log(int logType, const char* file, int line, const char* msg,
}
}
+std::string cmCTest::GetColorCode(Color color) const
+{
+ if (this->OutputColorCode) {
+#if defined(_WIN32)
+ // Not supported on Windows
+ static_cast<void>(color);
+#else
+ return "\033[0;" + std::to_string(static_cast<int>(color)) + "m";
+#endif
+ }
+
+ return "";
+}
+
cmDuration cmCTest::GetRemainingTimeAllowed()
{
if (!this->GetHandler("script")) {