MCPcopy Create free account
hub / github.com/Kitware/CMake / cmSetTestsPropertiesCommand

Function cmSetTestsPropertiesCommand

Source/cmSetTestsPropertiesCommand.cxx:18–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16#include "cmTest.h"
17
18bool cmSetTestsPropertiesCommand(std::vector<std::string> const& args,
19 cmExecutionStatus& status)
20{
21 if (args.empty()) {
22 status.SetError("called with incorrect number of arguments");
23 return false;
24 }
25
26 // first identify the properties arguments
27 auto propsIter = std::find(args.begin(), args.end(), "PROPERTIES");
28 if (propsIter == args.end() || propsIter + 1 == args.end()) {
29 status.SetError("called with illegal arguments, maybe missing a "
30 "PROPERTIES specifier?");
31 return false;
32 }
33
34 if (std::distance(propsIter, args.end()) % 2 != 1) {
35 status.SetError("called with incorrect number of arguments.");
36 return false;
37 }
38
39 std::vector<std::string> tests;
40 std::string directory;
41 cmArgumentParser<void> parser;
42 parser.Bind("DIRECTORY"_s, directory);
43 auto result = parser.Parse(cmStringRange{ args.begin(), propsIter }, &tests);
44
45 cmMakefile* mf = &status.GetMakefile();
46 if (result.MaybeReportError(*mf)) {
47 return false;
48 }
49 if (!directory.empty()) {
50 std::string absDirectory = cmSystemTools::CollapseFullPath(
51 directory, mf->GetCurrentSourceDirectory());
52 mf = mf->GetGlobalGenerator()->FindMakefile(absDirectory);
53 if (!mf) {
54 status.SetError(cmStrCat("given non-existent DIRECTORY ", directory));
55 return false;
56 }
57 }
58
59 // loop over all the tests
60 for (std::string const& tname : tests) {
61 if (cmTest* test = mf->GetTest(tname)) {
62 // loop through all the props and set them
63 for (auto k = propsIter + 1; k != args.end(); k += 2) {
64 if (!k->empty()) {
65 test->SetProperty(*k, *(k + 1));
66 }
67 }
68 } else {
69 status.SetError(
70 cmStrCat("Can not find test to add properties to: ", tname));
71 return false;
72 }
73 }
74 return true;
75}

Callers

nothing calls this directly

Calls 14

MaybeReportErrorMethod · 0.80
FindMakefileMethod · 0.80
cmStrCatFunction · 0.70
findFunction · 0.50
emptyMethod · 0.45
SetErrorMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
BindMethod · 0.45
ParseMethod · 0.45
GetMakefileMethod · 0.45
GetGlobalGeneratorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…