Coverage Report

Created: 2026-06-15 07:03

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/CMake/Source/cmTest.h
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
#pragma once
4
5
#include "cmConfigure.h" // IWYU pragma: keep
6
7
#include <cstddef>
8
#include <string>
9
#include <vector>
10
11
#include "cmListFileCache.h"
12
#include "cmPolicies.h"
13
#include "cmPropertyMap.h"
14
#include "cmValue.h"
15
16
class cmMakefile;
17
18
/** \class cmTest
19
 * \brief Represent a test
20
 *
21
 * cmTest is representation of a test.
22
 */
23
class cmTest
24
{
25
public:
26
  /**
27
   */
28
  cmTest(cmMakefile* mf);
29
  ~cmTest();
30
31
  //! Set the test name
32
  void SetName(std::string const& name);
33
0
  std::string GetName() const { return this->Name; }
34
35
  void SetCommand(std::vector<std::string> const& command);
36
0
  std::vector<std::string> const& GetCommand() const { return this->Command; }
37
38
  void SetBuildDependencies(std::vector<std::string> deps);
39
  std::vector<std::string> const& GetDependencies() const
40
0
  {
41
0
    return this->BuildDependencies;
42
0
  }
43
44
  //! Set/Get a property of this source file
45
  void SetProperty(std::string const& prop, cmValue value);
46
  void SetProperty(std::string const& prop, std::nullptr_t)
47
0
  {
48
0
    this->SetProperty(prop, cmValue{ nullptr });
49
0
  }
50
  void SetProperty(std::string const& prop, std::string const& value)
51
0
  {
52
0
    this->SetProperty(prop, cmValue(value));
53
0
  }
54
  void AppendProperty(std::string const& prop, std::string const& value,
55
                      bool asString = false);
56
  cmValue GetProperty(std::string const& prop) const;
57
  bool GetPropertyAsBool(std::string const& prop) const;
58
0
  cmPropertyMap& GetProperties() { return this->Properties; }
59
60
  /** Get the cmMakefile instance that owns this test.  */
61
0
  cmMakefile* GetMakefile() { return this->Makefile; }
62
63
  /** Get the backtrace of the command that created this test.  */
64
  cmListFileBacktrace const& GetBacktrace() const;
65
66
  /** Get/Set whether this is an old-style test.  */
67
0
  bool GetOldStyle() const { return this->OldStyle; }
68
0
  void SetOldStyle(bool b) { this->OldStyle = b; }
69
70
  /** Get the CMP0158 policy setting */
71
  cmPolicies::PolicyStatus GetCMP0158() const
72
0
  {
73
0
    return this->PolicyStatusCMP0158;
74
0
  }
75
76
  /** Get/Set the CMP0178 policy setting */
77
  cmPolicies::PolicyStatus GetCMP0178() const
78
0
  {
79
0
    return this->PolicyStatusCMP0178;
80
0
  }
81
  void SetCMP0178(cmPolicies::PolicyStatus p)
82
0
  {
83
0
    this->PolicyStatusCMP0178 = p;
84
0
  }
85
86
  /** Set/Get whether lists in command lines should be expanded. */
87
  bool GetCommandExpandLists() const;
88
  void SetCommandExpandLists(bool b);
89
90
private:
91
  cmPropertyMap Properties;
92
  std::string Name;
93
  std::vector<std::string> Command;
94
  std::vector<std::string> BuildDependencies;
95
  bool CommandExpandLists = false;
96
97
  bool OldStyle;
98
99
  cmMakefile* Makefile;
100
  cmListFileBacktrace Backtrace;
101
  cmPolicies::PolicyStatus PolicyStatusCMP0158;
102
  cmPolicies::PolicyStatus PolicyStatusCMP0178;
103
};