instrumentation: Add showOnly to ctest snippets

Fixes: #27269
This commit is contained in:
Martin Duffy
2025-10-22 10:17:46 -04:00
parent 2976742520
commit de3cb099a3
4 changed files with 12 additions and 1 deletions

View File

@@ -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

View File

@@ -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");

View File

@@ -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;
}

View File

@@ -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)