From b11e8afbfafde5ab70b796b664d82b2684dd272e Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Mon, 17 Jul 2023 22:47:53 +0200 Subject: ctest: export test labels to junit xml With this patch, the junit files written by ctest also contain the test labels as testcase properties, see https://github.com/testmoapp/junitxml#properties The name for the property is "cmake_labels", where "cmake_" is used namespace-like. This could be done the same way if we export more properties to junit. Also this makes it clear to consumers that this is coming from cmake, and the list is a cmake-formatted string. --- Source/CTest/cmCTestTestHandler.cxx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 6b02a5e..5ac696b 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -2617,6 +2617,21 @@ bool cmCTestTestHandler::WriteJUnitXML() xml.EndElement(); // } + xml.StartElement("properties"); + if ((result.Properties) && (!result.Properties->Labels.empty())) { + xml.StartElement("property"); + xml.Attribute("name", "cmake_labels"); + // Pass the property as a cmake-formatted list, consumers will know + // anyway that this information is coming from cmake, so it should + // be ok to put it here as a cmake-list. + xml.Attribute("value", cmList::to_string(result.Properties->Labels)); + // if we export more properties, this should be done the same way, + // i.e. prefix the property name with "cmake_", and it it can be + // a list, write it cmake-formatted. + xml.EndElement(); // + } + xml.EndElement(); // + // Note: compressed test output is unconditionally disabled when // --output-junit is specified. xml.Element("system-out", result.Output); -- cgit v0.12 From 2b99e64413ba6750deda892d7398906ade7b3737 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Tue, 18 Jul 2023 23:23:47 +0200 Subject: set_test_properties: link to the test properties in the documentation It was linking to the target properties, this was probably an oversight. --- Help/command/set_tests_properties.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Help/command/set_tests_properties.rst b/Help/command/set_tests_properties.rst index 125e460..1df9d73 100644 --- a/Help/command/set_tests_properties.rst +++ b/Help/command/set_tests_properties.rst @@ -20,4 +20,4 @@ See Also * :command:`add_test` * :command:`define_property` * the more general :command:`set_property` command -* :ref:`Target Properties` for the list of properties known to CMake +* :ref:`Test Properties` for the list of properties known to CMake -- cgit v0.12