summaryrefslogtreecommitdiffstats
path: root/Source/cmServerProtocol.cxx
diff options
context:
space:
mode:
authorJustin Goshi <jgoshi@microsoft.com>2017-11-14 21:42:32 (GMT)
committerJustin Goshi <jgoshi@microsoft.com>2017-11-17 17:19:26 (GMT)
commitfe2c2b0ffb567ca7d51036c69845091f70736a50 (patch)
tree4a61f5a8062b3e737bd8bea228b5309cb60148f4 /Source/cmServerProtocol.cxx
parentd23a0c4d0e35d50f8f3f1a950a68df576294a77a (diff)
downloadCMake-fe2c2b0ffb567ca7d51036c69845091f70736a50.zip
CMake-fe2c2b0ffb567ca7d51036c69845091f70736a50.tar.gz
CMake-fe2c2b0ffb567ca7d51036c69845091f70736a50.tar.bz2
server: ctestInfo fix to return all tests
Prior to this change we were looking at targets. But tests are associated with directories. This change fixes how we gather all tests.
Diffstat (limited to 'Source/cmServerProtocol.cxx')
-rw-r--r--Source/cmServerProtocol.cxx91
1 files changed, 19 insertions, 72 deletions
diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx
index 07df488..a997232 100644
--- a/Source/cmServerProtocol.cxx
+++ b/Source/cmServerProtocol.cxx
@@ -771,10 +771,10 @@ static void DumpBacktraceRange(Json::Value& result, const std::string& type,
}
}
-static Json::Value DumpCTestInfo(const std::string& name, cmTest* testInfo)
+static Json::Value DumpCTestInfo(cmTest* testInfo)
{
Json::Value result = Json::objectValue;
- result[kCTEST_NAME] = name;
+ result[kCTEST_NAME] = testInfo->GetName();
// Concat command entries together. After the first should be the arguments
// for the command
@@ -801,76 +801,17 @@ static Json::Value DumpCTestInfo(const std::string& name, cmTest* testInfo)
return result;
}
-static Json::Value DumpCTestTarget(cmGeneratorTarget* target,
- const std::string& config)
+static void DumpMakefileTests(cmMakefile* mf, const std::string& config,
+ Json::Value* result)
{
- cmLocalGenerator* lg = target->GetLocalGenerator();
- const cmState* state = lg->GetState();
-
- const cmStateEnums::TargetType type = target->GetType();
- const std::string typeName = state->GetTargetTypeName(type);
-
- Json::Value ttl = Json::arrayValue;
- ttl.append("EXECUTABLE");
- ttl.append("STATIC_LIBRARY");
- ttl.append("SHARED_LIBRARY");
- ttl.append("MODULE_LIBRARY");
- ttl.append("OBJECT_LIBRARY");
- ttl.append("UTILITY");
- ttl.append("INTERFACE_LIBRARY");
-
- if (!hasString(ttl, typeName) || target->IsImported()) {
- return Json::Value();
- }
-
- Json::Value result = Json::objectValue;
- result[kNAME_KEY] = target->GetName();
- result[kTYPE_KEY] = typeName;
-
- if (type == cmStateEnums::INTERFACE_LIBRARY) {
- return result;
- }
- result[kFULL_NAME_KEY] = target->GetFullName(config);
-
- if (target->Makefile->IsOn("CMAKE_TESTING_ENABLED")) {
- result[kHAS_ENABLED_TESTS] = true;
- std::vector<std::string> CTestNames;
-
- Json::Value testInfo = Json::arrayValue;
- std::vector<std::string> testNames;
- target->Makefile->GetTestNames(testNames);
- for (auto& name : testNames) {
- auto test = target->Makefile->GetTest(name);
- if (test != nullptr) {
- testInfo.append(DumpCTestInfo(name, test));
- }
- }
- result[kCTEST_INFO] = testInfo;
- }
-
- return result;
-}
-
-static Json::Value DumpCTestTargetsList(
- const std::vector<cmLocalGenerator*>& generators, const std::string& config)
-{
- Json::Value result = Json::arrayValue;
-
- std::vector<cmGeneratorTarget*> targetList;
- for (const auto& lgIt : generators) {
- auto list = lgIt->GetGeneratorTargets();
- targetList.insert(targetList.end(), list.begin(), list.end());
- }
- std::sort(targetList.begin(), targetList.end());
-
- for (cmGeneratorTarget* target : targetList) {
- Json::Value tmp = DumpCTestTarget(target, config);
+ std::vector<cmTest*> tests;
+ mf->GetTests(config, tests);
+ for (auto test : tests) {
+ Json::Value tmp = DumpCTestInfo(test);
if (!tmp.isNull()) {
- result.append(tmp);
+ result->append(tmp);
}
}
-
- return result;
}
static Json::Value DumpCTestProjectList(const cmake* cm,
@@ -884,11 +825,17 @@ static Json::Value DumpCTestProjectList(const cmake* cm,
Json::Value pObj = Json::objectValue;
pObj[kNAME_KEY] = projectIt.first;
- // All Projects must have at least one local generator
- assert(!projectIt.second.empty());
+ Json::Value tests = Json::arrayValue;
- // Project structure information:
- pObj[kTARGETS_KEY] = DumpCTestTargetsList(projectIt.second, config);
+ // Gather tests for every generator
+ for (const auto& lg : projectIt.second) {
+ // Make sure they're generated.
+ lg->GenerateTestFiles();
+ cmMakefile* mf = lg->GetMakefile();
+ DumpMakefileTests(mf, config, &tests);
+ }
+
+ pObj[kCTEST_INFO] = tests;
result.append(pObj);
}