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.
This commit is contained in:
parent
d23a0c4d0e
commit
fe2c2b0ffb
@ -656,25 +656,8 @@ Each project object can have the following keys:
|
|||||||
|
|
||||||
"name"
|
"name"
|
||||||
contains the (sub-)projects name.
|
contains the (sub-)projects name.
|
||||||
"targets"
|
|
||||||
contains a list of build system target objects.
|
|
||||||
|
|
||||||
Target objects define individual build targets for a certain configuration.
|
|
||||||
|
|
||||||
Each target object can have the following keys:
|
|
||||||
|
|
||||||
"name"
|
|
||||||
contains the name of the target.
|
|
||||||
"type"
|
|
||||||
defines the type of build of the target. Possible values are
|
|
||||||
"STATIC_LIBRARY", "MODULE_LIBRARY", "SHARED_LIBRARY", "OBJECT_LIBRARY",
|
|
||||||
"EXECUTABLE", "UTILITY" and "INTERFACE_LIBRARY".
|
|
||||||
"fullName"
|
|
||||||
contains the full name of the build result (incl. extensions, etc.).
|
|
||||||
"hasEnabledTests"
|
|
||||||
true if testing is enabled for this target.
|
|
||||||
"ctestInfo"
|
"ctestInfo"
|
||||||
contains a list of test objects for this target.
|
contains a list of test objects.
|
||||||
|
|
||||||
Each test object can have the following keys:
|
Each test object can have the following keys:
|
||||||
|
|
||||||
|
@ -3319,13 +3319,6 @@ cmGlobalGenerator* cmMakefile::GetGlobalGenerator() const
|
|||||||
return this->GlobalGenerator;
|
return this->GlobalGenerator;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmMakefile::GetTestNames(std::vector<std::string>& testNames)
|
|
||||||
{
|
|
||||||
for (const auto& iter : Tests) {
|
|
||||||
testNames.push_back(iter.first);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef CMAKE_BUILD_WITH_CMAKE
|
#ifdef CMAKE_BUILD_WITH_CMAKE
|
||||||
cmVariableWatch* cmMakefile::GetVariableWatch() const
|
cmVariableWatch* cmMakefile::GetVariableWatch() const
|
||||||
{
|
{
|
||||||
@ -3661,6 +3654,16 @@ cmTest* cmMakefile::GetTest(const std::string& testName) const
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cmMakefile::GetTests(const std::string& config,
|
||||||
|
std::vector<cmTest*>& tests)
|
||||||
|
{
|
||||||
|
for (auto generator : this->GetTestGenerators()) {
|
||||||
|
if (generator->TestsForConfig(config)) {
|
||||||
|
tests.push_back(generator->GetTest());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void cmMakefile::AddCMakeDependFilesFromUser()
|
void cmMakefile::AddCMakeDependFilesFromUser()
|
||||||
{
|
{
|
||||||
std::vector<std::string> deps;
|
std::vector<std::string> deps;
|
||||||
|
@ -616,11 +616,6 @@ public:
|
|||||||
cmMessenger* GetMessenger() const;
|
cmMessenger* GetMessenger() const;
|
||||||
cmGlobalGenerator* GetGlobalGenerator() const;
|
cmGlobalGenerator* GetGlobalGenerator() const;
|
||||||
|
|
||||||
/**
|
|
||||||
* Get all the test names this makefile knows about
|
|
||||||
*/
|
|
||||||
void GetTestNames(std::vector<std::string>& testNames);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all the source files this makefile knows about
|
* Get all the source files this makefile knows about
|
||||||
*/
|
*/
|
||||||
@ -643,6 +638,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
cmTest* GetTest(const std::string& testName) const;
|
cmTest* GetTest(const std::string& testName) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all tests that run under the given configuration.
|
||||||
|
*/
|
||||||
|
void GetTests(const std::string& config, std::vector<cmTest*>& tests);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a location of a file in cmake or custom modules directory
|
* Return a location of a file in cmake or custom modules directory
|
||||||
*/
|
*/
|
||||||
|
@ -91,7 +91,6 @@ static const std::string kWATCHED_DIRECTORIES_KEY = "watchedDirectories";
|
|||||||
static const std::string kWATCHED_FILES_KEY = "watchedFiles";
|
static const std::string kWATCHED_FILES_KEY = "watchedFiles";
|
||||||
static const std::string kHAS_INSTALL_RULE = "hasInstallRule";
|
static const std::string kHAS_INSTALL_RULE = "hasInstallRule";
|
||||||
static const std::string kINSTALL_PATHS = "installPaths";
|
static const std::string kINSTALL_PATHS = "installPaths";
|
||||||
static const std::string kHAS_ENABLED_TESTS = "hasEnabledTests";
|
|
||||||
static const std::string kCTEST_NAME = "ctestName";
|
static const std::string kCTEST_NAME = "ctestName";
|
||||||
static const std::string kCTEST_COMMAND = "ctestCommand";
|
static const std::string kCTEST_COMMAND = "ctestCommand";
|
||||||
static const std::string kCTEST_INFO = "ctestInfo";
|
static const std::string kCTEST_INFO = "ctestInfo";
|
||||||
|
@ -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;
|
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
|
// Concat command entries together. After the first should be the arguments
|
||||||
// for the command
|
// for the command
|
||||||
@ -801,76 +801,17 @@ static Json::Value DumpCTestInfo(const std::string& name, cmTest* testInfo)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Json::Value DumpCTestTarget(cmGeneratorTarget* target,
|
static void DumpMakefileTests(cmMakefile* mf, const std::string& config,
|
||||||
const std::string& config)
|
Json::Value* result)
|
||||||
{
|
{
|
||||||
cmLocalGenerator* lg = target->GetLocalGenerator();
|
std::vector<cmTest*> tests;
|
||||||
const cmState* state = lg->GetState();
|
mf->GetTests(config, tests);
|
||||||
|
for (auto test : tests) {
|
||||||
const cmStateEnums::TargetType type = target->GetType();
|
Json::Value tmp = DumpCTestInfo(test);
|
||||||
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);
|
|
||||||
if (!tmp.isNull()) {
|
if (!tmp.isNull()) {
|
||||||
result.append(tmp);
|
result->append(tmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Json::Value DumpCTestProjectList(const cmake* cm,
|
static Json::Value DumpCTestProjectList(const cmake* cm,
|
||||||
@ -884,11 +825,17 @@ static Json::Value DumpCTestProjectList(const cmake* cm,
|
|||||||
Json::Value pObj = Json::objectValue;
|
Json::Value pObj = Json::objectValue;
|
||||||
pObj[kNAME_KEY] = projectIt.first;
|
pObj[kNAME_KEY] = projectIt.first;
|
||||||
|
|
||||||
// All Projects must have at least one local generator
|
Json::Value tests = Json::arrayValue;
|
||||||
assert(!projectIt.second.empty());
|
|
||||||
|
|
||||||
// Project structure information:
|
// Gather tests for every generator
|
||||||
pObj[kTARGETS_KEY] = DumpCTestTargetsList(projectIt.second, config);
|
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);
|
result.append(pObj);
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,16 @@ void cmTestGenerator::Compute(cmLocalGenerator* lg)
|
|||||||
this->LG = lg;
|
this->LG = lg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool cmTestGenerator::TestsForConfig(const std::string& config)
|
||||||
|
{
|
||||||
|
return this->GeneratesForConfig(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
cmTest* cmTestGenerator::GetTest() const
|
||||||
|
{
|
||||||
|
return this->Test;
|
||||||
|
}
|
||||||
|
|
||||||
void cmTestGenerator::GenerateScriptConfigs(std::ostream& os, Indent indent)
|
void cmTestGenerator::GenerateScriptConfigs(std::ostream& os, Indent indent)
|
||||||
{
|
{
|
||||||
// Create the tests.
|
// Create the tests.
|
||||||
|
@ -30,6 +30,11 @@ public:
|
|||||||
|
|
||||||
void Compute(cmLocalGenerator* lg);
|
void Compute(cmLocalGenerator* lg);
|
||||||
|
|
||||||
|
/** Test if this generator installs the test for a given configuration. */
|
||||||
|
bool TestsForConfig(const std::string& config);
|
||||||
|
|
||||||
|
cmTest* GetTest() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void GenerateScriptConfigs(std::ostream& os, Indent indent) override;
|
void GenerateScriptConfigs(std::ostream& os, Indent indent) override;
|
||||||
void GenerateScriptActions(std::ostream& os, Indent indent) override;
|
void GenerateScriptActions(std::ostream& os, Indent indent) override;
|
||||||
|
Loading…
Reference in New Issue
Block a user