[Cmake-commits] CMake branch, master, updated. v3.13.0-rc3-416-gd3b932f

Kitware Robot kwrobot at kitware.com
Tue Nov 13 10:33:41 EST 2018


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, master has been updated
       via  d3b932fa678516d3f5bb7f7209547a876a182d02 (commit)
       via  71e77972c18e1ab905b36782d7b2c2f838957e26 (commit)
       via  ffdec37a197499929e2cbc4fa825f5bf9b7d0f26 (commit)
       via  1222f02e343e804f1fcc8ff09e56dc13ac233d98 (commit)
      from  5e12fad8704e4797ecda3906f3b558775b70539f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d3b932fa678516d3f5bb7f7209547a876a182d02
commit d3b932fa678516d3f5bb7f7209547a876a182d02
Merge: 71e7797 ffdec37
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Nov 13 15:31:19 2018 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Tue Nov 13 10:32:05 2018 -0500

    Merge topic 'colored-ctest-summary'
    
    ffdec37a19 CTest: Add colored output on tests summary where supported
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !2577


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=71e77972c18e1ab905b36782d7b2c2f838957e26
commit 71e77972c18e1ab905b36782d7b2c2f838957e26
Merge: 5e12fad 1222f02
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Nov 13 15:29:21 2018 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Tue Nov 13 10:29:36 2018 -0500

    Merge topic 'if_support_checking_if_cache_var_defined'
    
    1222f02e34 If: Support the 'DEFINED CACHE{}' syntax
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !2561


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ffdec37a197499929e2cbc4fa825f5bf9b7d0f26
commit ffdec37a197499929e2cbc4fa825f5bf9b7d0f26
Author:     Sylvain Joubert <joubert.sy at gmail.com>
AuthorDate: Wed Nov 7 16:33:28 2018 +0100
Commit:     Sylvain Joubert <joubert.sy at gmail.com>
CommitDate: Fri Nov 9 18:57:41 2018 +0100

    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

diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx
index c936910..1d938e6 100644
--- a/Source/CTest/cmCTestTestHandler.cxx
+++ b/Source/CTest/cmCTestTestHandler.cxx
@@ -535,11 +535,21 @@ int cmCTestTestHandler::ProcessHandler()
       percent = 99;
     }
 
+    std::string passColorCode;
+    std::string failedColorCode;
+    if (failed.empty()) {
+      passColorCode = this->CTest->GetColorCode(cmCTest::Color::GREEN);
+    } else {
+      failedColorCode = this->CTest->GetColorCode(cmCTest::Color::RED);
+    }
     cmCTestLog(this->CTest, HANDLER_OUTPUT,
                std::endl
-                 << static_cast<int>(percent + .5f) << "% tests passed, "
-                 << failed.size() << " tests failed out of " << total
-                 << std::endl);
+                 << passColorCode << static_cast<int>(percent + .5f)
+                 << "% tests passed"
+                 << this->CTest->GetColorCode(cmCTest::Color::CLEAR_COLOR)
+                 << ", " << failedColorCode << failed.size() << " tests failed"
+                 << this->CTest->GetColorCode(cmCTest::Color::CLEAR_COLOR)
+                 << " out of " << total << std::endl);
     if ((!this->CTest->GetLabelsForSubprojects().empty() &&
          this->CTest->GetSubprojectSummary())) {
       this->PrintLabelOrSubprojectSummary(true);
@@ -562,6 +572,8 @@ int cmCTestTestHandler::ProcessHandler()
       this->StartLogFile("TestsDisabled", ofs);
 
       const char* disabled_reason;
+      cmCTestLog(this->CTest, HANDLER_OUTPUT,
+                 this->CTest->GetColorCode(cmCTest::Color::BLUE));
       for (cmCTestTestResult const& dt : disabledTests) {
         ofs << dt.TestCount << ":" << dt.Name << std::endl;
         if (dt.CompletionStatus == "Disabled") {
@@ -573,6 +585,8 @@ int cmCTestTestHandler::ProcessHandler()
                    "\t" << std::setw(3) << dt.TestCount << " - " << dt.Name
                         << " (" << disabled_reason << ")" << std::endl);
       }
+      cmCTestLog(this->CTest, HANDLER_OUTPUT,
+                 this->CTest->GetColorCode(cmCTest::Color::CLEAR_COLOR));
     }
 
     if (!failed.empty()) {
@@ -587,10 +601,17 @@ int cmCTestTestHandler::ProcessHandler()
             !cmHasLiteralPrefix(ft.CompletionStatus, "SKIP_RETURN_CODE=") &&
             ft.CompletionStatus != "Disabled") {
           ofs << ft.TestCount << ":" << ft.Name << std::endl;
-          cmCTestLog(this->CTest, HANDLER_OUTPUT,
-                     "\t" << std::setw(3) << ft.TestCount << " - " << ft.Name
-                          << " (" << this->GetTestStatus(ft) << ")"
-                          << std::endl);
+          auto testColor = cmCTest::Color::RED;
+          if (this->GetTestStatus(ft) == "Not Run") {
+            testColor = cmCTest::Color::YELLOW;
+          }
+          cmCTestLog(
+            this->CTest, HANDLER_OUTPUT,
+            "\t" << this->CTest->GetColorCode(testColor) << std::setw(3)
+                 << ft.TestCount << " - " << ft.Name << " ("
+                 << this->GetTestStatus(ft) << ")"
+                 << this->CTest->GetColorCode(cmCTest::Color::CLEAR_COLOR)
+                 << std::endl);
         }
       }
     }
@@ -1725,7 +1746,7 @@ void cmCTestTestHandler::UseExcludeRegExp()
   this->UseExcludeRegExpFirst = !this->UseIncludeRegExpFlag;
 }
 
-const char* cmCTestTestHandler::GetTestStatus(cmCTestTestResult const& result)
+std::string cmCTestTestHandler::GetTestStatus(cmCTestTestResult const& result)
 {
   static const char* statuses[] = { "Not Run",     "Timeout",   "SEGFAULT",
                                     "ILLEGAL",     "INTERRUPT", "NUMERICAL",
@@ -1737,7 +1758,7 @@ const char* cmCTestTestHandler::GetTestStatus(cmCTestTestResult const& result)
     return "No Status";
   }
   if (status == cmCTestTestHandler::OTHER_FAULT) {
-    return result.ExceptionStatus.c_str();
+    return result.ExceptionStatus;
   }
   return statuses[status];
 }
diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h
index d2694a1..bcacf23 100644
--- a/Source/CTest/cmCTestTestHandler.h
+++ b/Source/CTest/cmCTestTestHandler.h
@@ -274,7 +274,7 @@ private:
    */
   std::string FindTheExecutable(const char* exe);
 
-  const char* GetTestStatus(cmCTestTestResult const&);
+  std::string GetTestStatus(cmCTestTestResult const&);
   void ExpandTestsToRunInformation(size_t numPossibleTests);
   void ExpandTestsToRunInformationForRerunFailed();
 
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")) {
diff --git a/Source/cmCTest.h b/Source/cmCTest.h
index 1ee002a..427049d 100644
--- a/Source/cmCTest.h
+++ b/Source/cmCTest.h
@@ -405,6 +405,19 @@ public:
   void Log(int logType, const char* file, int line, const char* msg,
            bool suppress = false);
 
+  /** Color values */
+  enum class Color
+  {
+    CLEAR_COLOR = 0,
+    RED = 31,
+    GREEN = 32,
+    YELLOW = 33,
+    BLUE = 34
+  };
+
+  /** Get color code characters for a specific color */
+  std::string GetColorCode(Color color) const;
+
   /** Get the version of dart server */
   int GetDartVersion() { return this->DartVersion; }
   int GetDropSiteCDash() { return this->DropSiteCDash; }
@@ -575,8 +588,16 @@ private:
   bool HandleCommandLineArguments(size_t& i, std::vector<std::string>& args,
                                   std::string& errormsg);
 
+#if !defined(_WIN32)
   /** returns true iff the console supports progress output */
-  bool ProgressOutputSupportedByConsole() const;
+  static bool ConsoleIsNotDumb();
+#endif
+
+  /** returns true iff the console supports progress output */
+  static bool ProgressOutputSupportedByConsole();
+
+  /** returns true iff the console supports colored output */
+  static bool ColoredOutputSupportedByConsole();
 
   /** handle the -S -SP and -SR arguments */
   void HandleScriptArguments(size_t& i, std::vector<std::string>& args,
@@ -625,6 +646,7 @@ private:
   int OutputLogFileLastTag;
 
   bool OutputTestOutputOnTestFailure;
+  bool OutputColorCode;
 
   std::map<std::string, std::string> Definitions;
 };

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1222f02e343e804f1fcc8ff09e56dc13ac233d98
commit 1222f02e343e804f1fcc8ff09e56dc13ac233d98
Author:     Robert Maynard <robert.maynard at kitware.com>
AuthorDate: Fri Nov 2 17:27:09 2018 -0400
Commit:     Robert Maynard <robert.maynard at kitware.com>
CommitDate: Fri Nov 9 10:38:07 2018 -0500

    If: Support the 'DEFINED CACHE{}' syntax

diff --git a/Help/command/if.rst b/Help/command/if.rst
index 1cd9965..a682c83 100644
--- a/Help/command/if.rst
+++ b/Help/command/if.rst
@@ -187,11 +187,10 @@ Possible conditions are:
 ``if(<variable|string> IN_LIST <variable>)``
  True if the given element is contained in the named list variable.
 
-``if(DEFINED <name>|ENV{<name>})``
- True if a variable or environment variable
- with given ``<name>`` is defined.
- The value of the variable does not matter.
- Note that macro arguments are not variables.
+``if(DEFINED <name>|CACHE{<name>}|ENV{<name>})``
+ True if a variable, cache variable or environment variable
+ with given ``<name>`` is defined. The value of the variable
+ does not matter. Note that macro arguments are not variables.
 
 ``if((condition) AND (condition OR (condition)))``
  The conditions inside the parenthesis are evaluated first and then
diff --git a/Help/release/dev/if-supports-cache-defined.rst b/Help/release/dev/if-supports-cache-defined.rst
new file mode 100644
index 0000000..1e700c0
--- /dev/null
+++ b/Help/release/dev/if-supports-cache-defined.rst
@@ -0,0 +1,5 @@
+if-supports-cache-defined
+-------------------------
+
+* The :command:`if` command gained support for checking if cache variables
+  are defined with the  ``DEFINED CACHE{VAR}`` syntax.
diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx
index 172ef92..3b4206f 100644
--- a/Source/cmConditionEvaluator.cxx
+++ b/Source/cmConditionEvaluator.cxx
@@ -495,6 +495,12 @@ bool cmConditionEvaluator::HandleLevel1(cmArgumentList& newArgs, std::string&,
             argP1->GetValue().operator[](argP1len - 1) == '}') {
           std::string env = argP1->GetValue().substr(4, argP1len - 5);
           bdef = cmSystemTools::HasEnv(env);
+        } else if (argP1len > 6 &&
+                   argP1->GetValue().substr(0, 6) == "CACHE{" &&
+                   argP1->GetValue().operator[](argP1len - 1) == '}') {
+          std::string cache = argP1->GetValue().substr(6, argP1len - 7);
+          bdef =
+            this->Makefile.GetState()->GetCacheEntryValue(cache) != nullptr;
         } else {
           bdef = this->Makefile.IsDefinitionSet(argP1->GetValue());
         }
diff --git a/Tests/Unset/CMakeLists.txt b/Tests/Unset/CMakeLists.txt
index 07aa68e..a40367b 100644
--- a/Tests/Unset/CMakeLists.txt
+++ b/Tests/Unset/CMakeLists.txt
@@ -21,17 +21,26 @@ set(x 43)
 if(NOT x EQUAL 43)
   message(FATAL_ERROR "x!=43")
 endif()
+if(DEFINED CACHE{x})
+  message(FATAL_ERROR "x shouldn't be found in the cache")
+endif()
+
 set(x)
 if(DEFINED x)
   message(FATAL_ERROR "x should be undefined now!")
 endif()
 
+
 # Cache variable
 set(BAR "test" CACHE STRING "documentation")
 if(NOT DEFINED BAR)
   message(FATAL_ERROR "BAR not defined")
 endif()
 
+if(NOT DEFINED CACHE{BAR})
+  message(FATAL_ERROR "BAR could not be found by CACHE{BAR}")
+endif()
+
 # Test interaction of cache entries with variables.
 set(BAR "test-var")
 if(NOT "$CACHE{BAR}" STREQUAL "test")

-----------------------------------------------------------------------

Summary of changes:
 Help/command/if.rst                            |  9 +++---
 Help/release/dev/if-supports-cache-defined.rst |  5 +++
 Source/CTest/cmCTestTestHandler.cxx            | 39 +++++++++++++++++------
 Source/CTest/cmCTestTestHandler.h              |  2 +-
 Source/cmCTest.cxx                             | 43 +++++++++++++++++++++++---
 Source/cmCTest.h                               | 24 +++++++++++++-
 Source/cmConditionEvaluator.cxx                |  6 ++++
 Tests/Unset/CMakeLists.txt                     |  9 ++++++
 8 files changed, 116 insertions(+), 21 deletions(-)
 create mode 100644 Help/release/dev/if-supports-cache-defined.rst


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list