Coverage Report

Created: 2026-02-09 06:05

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/CMake/Source/cmGetTestPropertyCommand.cxx
Line
Count
Source
1
/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2
   file LICENSE.rst or https://cmake.org/licensing for details.  */
3
#include "cmGetTestPropertyCommand.h"
4
5
#include "cmExecutionStatus.h"
6
#include "cmMakefile.h"
7
#include "cmSetPropertyCommand.h"
8
#include "cmTest.h"
9
#include "cmValue.h"
10
11
bool cmGetTestPropertyCommand(std::vector<std::string> const& args,
12
                              cmExecutionStatus& status)
13
0
{
14
0
  std::vector<std::string>::size_type args_size = args.size();
15
0
  if (args_size != 3 && args_size != 5) {
16
0
    status.SetError("called with incorrect number of arguments");
17
0
    return false;
18
0
  }
19
20
0
  std::string test_directory;
21
0
  bool test_directory_option_enabled = false;
22
23
0
  int var_arg_index = 2;
24
0
  if (args[2] == "DIRECTORY" && args_size == 5) {
25
0
    var_arg_index = 4;
26
0
    test_directory_option_enabled = true;
27
0
    test_directory = args[3];
28
0
  }
29
30
0
  cmMakefile* test_directory_makefile = &status.GetMakefile();
31
0
  bool file_scopes_handled =
32
0
    SetPropertyCommand::HandleAndValidateTestDirectoryScopes(
33
0
      status, test_directory_option_enabled, test_directory,
34
0
      test_directory_makefile);
35
0
  if (!file_scopes_handled) {
36
0
    return false;
37
0
  }
38
39
0
  std::string const& testName = args[0];
40
0
  std::string const& var = args[var_arg_index];
41
0
  cmMakefile& mf = status.GetMakefile();
42
0
  cmTest* test = test_directory_makefile->GetTest(testName);
43
0
  if (test) {
44
0
    cmValue prop;
45
0
    if (!args[1].empty()) {
46
0
      prop = test->GetProperty(args[1]);
47
0
    }
48
0
    if (prop) {
49
0
      mf.AddDefinition(var, prop);
50
0
      return true;
51
0
    }
52
0
  }
53
0
  mf.AddDefinition(var, "NOTFOUND");
54
0
  return true;
55
0
}