mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-28 18:09:42 -05:00
server: Expand generator expressions for test info
This commit is contained in:
@@ -748,7 +748,8 @@ static Json::Value DumpSourceFilesList(
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Json::Value DumpCTestInfo(cmTest* testInfo)
|
static Json::Value DumpCTestInfo(cmLocalGenerator* lg, cmTest* testInfo,
|
||||||
|
const std::string& config)
|
||||||
{
|
{
|
||||||
Json::Value result = Json::objectValue;
|
Json::Value result = Json::objectValue;
|
||||||
result[kCTEST_NAME] = testInfo->GetName();
|
result[kCTEST_NAME] = testInfo->GetName();
|
||||||
@@ -760,14 +761,24 @@ static Json::Value DumpCTestInfo(cmTest* testInfo)
|
|||||||
command.append(cmd);
|
command.append(cmd);
|
||||||
command.append(" ");
|
command.append(" ");
|
||||||
}
|
}
|
||||||
result[kCTEST_COMMAND] = command;
|
|
||||||
|
// Remove any config specific variables from the output.
|
||||||
|
cmGeneratorExpression ge;
|
||||||
|
auto cge = ge.Parse(command.c_str());
|
||||||
|
const char* processed = cge->Evaluate(lg, config);
|
||||||
|
|
||||||
|
result[kCTEST_COMMAND] = processed;
|
||||||
|
|
||||||
// Build up the list of properties that may have been specified
|
// Build up the list of properties that may have been specified
|
||||||
Json::Value properties = Json::arrayValue;
|
Json::Value properties = Json::arrayValue;
|
||||||
for (auto& prop : testInfo->GetProperties()) {
|
for (auto& prop : testInfo->GetProperties()) {
|
||||||
Json::Value entry = Json::objectValue;
|
Json::Value entry = Json::objectValue;
|
||||||
entry[kKEY_KEY] = prop.first;
|
entry[kKEY_KEY] = prop.first;
|
||||||
entry[kVALUE_KEY] = prop.second.GetValue();
|
|
||||||
|
// Remove config variables from the value too.
|
||||||
|
auto cge_value = ge.Parse(prop.second.GetValue());
|
||||||
|
const char* processed_value = cge_value->Evaluate(lg, config);
|
||||||
|
entry[kVALUE_KEY] = processed_value;
|
||||||
properties.append(entry);
|
properties.append(entry);
|
||||||
}
|
}
|
||||||
result[kPROPERTIES_KEY] = properties;
|
result[kPROPERTIES_KEY] = properties;
|
||||||
@@ -775,13 +786,14 @@ static Json::Value DumpCTestInfo(cmTest* testInfo)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DumpMakefileTests(cmMakefile* mf, const std::string& config,
|
static void DumpMakefileTests(cmLocalGenerator* lg, const std::string& config,
|
||||||
Json::Value* result)
|
Json::Value* result)
|
||||||
{
|
{
|
||||||
|
auto mf = lg->GetMakefile();
|
||||||
std::vector<cmTest*> tests;
|
std::vector<cmTest*> tests;
|
||||||
mf->GetTests(config, tests);
|
mf->GetTests(config, tests);
|
||||||
for (auto test : tests) {
|
for (auto test : tests) {
|
||||||
Json::Value tmp = DumpCTestInfo(test);
|
Json::Value tmp = DumpCTestInfo(lg, test, config);
|
||||||
if (!tmp.isNull()) {
|
if (!tmp.isNull()) {
|
||||||
result->append(tmp);
|
result->append(tmp);
|
||||||
}
|
}
|
||||||
@@ -805,8 +817,7 @@ static Json::Value DumpCTestProjectList(const cmake* cm,
|
|||||||
for (const auto& lg : projectIt.second) {
|
for (const auto& lg : projectIt.second) {
|
||||||
// Make sure they're generated.
|
// Make sure they're generated.
|
||||||
lg->GenerateTestFiles();
|
lg->GenerateTestFiles();
|
||||||
cmMakefile* mf = lg->GetMakefile();
|
DumpMakefileTests(lg, config, &tests);
|
||||||
DumpMakefileTests(mf, config, &tests);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pObj[kCTEST_INFO] = tests;
|
pObj[kCTEST_INFO] = tests;
|
||||||
|
|||||||
Reference in New Issue
Block a user