Browse Source

instrumentation: Add showOnly to ctest snippets

Fixes: #27269
Martin Duffy 2 weeks ago
parent
commit
de3cb099a3

+ 4 - 0
Help/manual/cmake-instrumentation.7.rst

@@ -423,6 +423,10 @@ and contain the following data:
     contains information about the CMake configure and generate steps
     responsible for generating the ``command`` in this snippet.
 
+  ``showOnly``
+    A boolean representing whether the ``--show-only`` option was passed to
+    ``ctest``. Only included when ``role`` is ``ctest``.
+
 Example:
 
 .. code-block:: json

+ 4 - 1
Source/cmCTest.cxx

@@ -2672,7 +2672,10 @@ int cmCTest::ExecuteTests(std::vector<std::string> const& args)
   auto processHandler = [&handler]() -> int {
     return handler.ProcessHandler();
   };
-  int ret = instrumentation.InstrumentCommand("ctest", args, processHandler);
+  std::map<std::string, std::string> data;
+  data["showOnly"] = this->GetShowOnly() ? "1" : "0";
+  int ret =
+    instrumentation.InstrumentCommand("ctest", args, processHandler, data);
   instrumentation.CollectTimingData(cmInstrumentationQuery::Hook::PostCTest);
   if (ret < 0) {
     cmCTestLog(this, ERROR_MESSAGE, "Errors while running CTest\n");

+ 2 - 0
Source/cmInstrumentation.cxx

@@ -663,6 +663,8 @@ int cmInstrumentation::InstrumentCommand(
     for (auto const& item : data.value()) {
       if (item.first == "role" && !item.second.empty()) {
         command_type = item.second;
+      } else if (item.first == "showOnly") {
+        root[item.first] = item.second == "1" ? true : false;
       } else if (!item.second.empty()) {
         root[item.first] = item.second;
       }

+ 2 - 0
Tests/RunCMake/Instrumentation/verify-snippet.cmake

@@ -27,6 +27,8 @@ function(snippet_has_fields snippet contents)
     json_has_key("${snippet}" "${contents}" outputs)
     json_has_key("${snippet}" "${contents}" outputSizes)
     json_has_key("${snippet}" "${contents}" config)
+  elseif (filename MATCHES "^ctest-*")
+    json_has_key("${snippet}" "${contents}" showOnly)
   elseif (filename MATCHES "^test-*")
     json_has_key("${snippet}" "${contents}" testName)
     json_has_key("${snippet}" "${contents}" config)