ctest: Show custom test properties in --show-only=json-v1

This commit is contained in:
Daniel Sim
2024-03-06 15:06:20 +00:00
parent ac411fc8b3
commit 06860d5c12
5 changed files with 21 additions and 1 deletions

View File

@@ -1166,6 +1166,11 @@ static Json::Value DumpCTestProperties(
properties.append(
DumpCTestProperty("WORKING_DIRECTORY", testProperties.Directory));
}
if (!testProperties.CustomProperties.empty()) {
for (auto const& it : testProperties.CustomProperties) {
properties.append(DumpCTestProperty(it.first, it.second));
}
}
return properties;
}

View File

@@ -2435,6 +2435,8 @@ bool cmCTestTestHandler::SetTestsProperties(
rt.TimeoutRegularExpressions.emplace_back(cr, cr);
}
}
} else {
rt.CustomProperties[key] = val;
}
}
}

View File

@@ -145,6 +145,7 @@ public:
std::vector<std::pair<cmsys::RegularExpression, std::string>>
TimeoutRegularExpressions;
std::map<std::string, std::string> Measurements;
std::map<std::string, std::string> CustomProperties;
bool IsInBasedOnREOptions = true;
bool WillFail = false;
bool Disabled = false;

View File

@@ -391,6 +391,8 @@ function(run_ShowOnly)
RESOURCE_GROUPS \"2,threads:2,gpus:4;gpus:2,threads:4\"
REQUIRED_FILES RequiredFileDoesNotExist
_BACKTRACE_TRIPLES \"file1;1;add_test;file0;;\"
USER_DEFINED_A \"User defined property A value\"
USER_DEFINED_B \"User defined property B value\"
)
add_test(ShowOnlyNotAvailable NOT_AVAILABLE)
")

View File

@@ -144,13 +144,23 @@ def check_workingdir_property(p):
assert p["name"] == "WORKING_DIRECTORY"
assert p["value"].endswith("Tests/RunCMake/CTestCommandLine/ShowOnly")
def check_defined_properties(p_list):
for property_id, p in zip(["A", "B"], p_list):
assert is_dict(p)
assert sorted(p.keys()) == ["name", "value"]
assert is_string(p["name"])
assert is_string(p["value"])
assert p["name"] == "USER_DEFINED_" + property_id
assert p["value"] == "User defined property " + property_id + " value"
def check_properties(p):
assert is_list(p)
assert len(p) == 4
assert len(p) == 6
check_resource_groups_property(p[0])
check_reqfiles_property(p[1])
check_willfail_property(p[2])
check_workingdir_property(p[3])
check_defined_properties(p[4:5])
def check_tests(t):
assert is_list(t)