From eb9e4ef9ba1b92f4ad71e56970652e8270b61b2a Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 8 Sep 2025 14:42:07 +0200 Subject: [PATCH] Pass CTest test description in custom property or environment Prior to this change, each test would have, as label, it's description. This leads to many labels, which are normally reserved for grouping tests. Move the description into a custom property instead. Since we rely on the JSON output for the generation of HTML reports, we need to also extract the description from the generated JSON. However, custom properties are only logged starting from cmake 3.30. For back-wards compatibility, write an additional, separate environment variable TEST_DESCRIPTION from which the description can be read as a fallback. For the add_timed_physim_test(), this has been already done in a parent commit. --- ci-scripts/cls_analysis.py | 19 ++++++++++++++++++- openair1/SIMULATION/tests/CMakeLists.txt | 10 ++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/ci-scripts/cls_analysis.py b/ci-scripts/cls_analysis.py index 240a89dc16..46b32bf449 100644 --- a/ci-scripts/cls_analysis.py +++ b/ci-scripts/cls_analysis.py @@ -28,6 +28,23 @@ import json class Analysis(): + def _get_test_description(properties): + env_vars = None + for p in properties: + if p["name"] == "ENVIRONMENT": + env_vars = p["value"] # save for later if no custom property + if p["name"] == "TEST_DESCRIPTION": + return p["value"] + # if we came till here, it means there is no custom test property + # saved in JSON. See if we have a description in environment variables + if not env_vars: + return "" + for ev in env_vars: + name, value = ev.split("=", 1) + if name == "TEST_DESCRIPTION": + return value + return "" + def analyze_physim(result_junit, details_json, logPath): try: tree = ET.parse(result_junit) @@ -60,7 +77,7 @@ class Analysis(): for test in root: # for each test test_name = test.attrib["name"] test_exec = json_test_desc[test_name]["properties"][1]["value"][0] - desc = json_test_desc[test_name]["properties"][1]["value"][1] + desc = Analysis._get_test_description(json_test_desc[test_name]["properties"]) # get runtime and checks test_check = test.attrib["status"] == "run" time = round(float(test.attrib["time"]), 1) diff --git a/openair1/SIMULATION/tests/CMakeLists.txt b/openair1/SIMULATION/tests/CMakeLists.txt index d71df315bb..273142a1d7 100644 --- a/openair1/SIMULATION/tests/CMakeLists.txt +++ b/openair1/SIMULATION/tests/CMakeLists.txt @@ -1,3 +1,5 @@ +define_property(TEST PROPERTY TEST_DESCRIPTION BRIEF_DOCS "A human-readable description of this test") + # Define a macro to add tests for different physical simulators macro(add_physim_test test_name test_description test_exec) # catch all the arguments past the last expected arqument and store them in the options_list @@ -11,8 +13,12 @@ macro(add_physim_test test_name test_description test_exec) COMMAND_EXPAND_LISTS ) set_tests_properties(${test_name} PROPERTIES - LABELS "${test_exec}: ${test_description};${test_exec}" - ENVIRONMENT "LD_LIBRARY_PATH=." + LABELS "${test_exec}" + TEST_DESCRIPTION "${test_description}" + # pass test description also through environment variable: for cmake < 3.30, + # in JSON export, we cannot recover the description otherwise + # see also https://gitlab.kitware.com/cmake/cmake/-/issues/21490 + ENVIRONMENT "LD_LIBRARY_PATH=.;TEST_DESCRIPTION=${test_description}" ) add_dependencies(tests ${test_exec}) endmacro()