cmTest.cxx 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #include "cmTest.h"
  4. #include "cmMakefile.h"
  5. #include "cmProperty.h"
  6. #include "cmState.h"
  7. #include "cmStringAlgorithms.h"
  8. cmTest::cmTest(cmMakefile* mf)
  9. : CommandExpandLists(false)
  10. , Backtrace(mf->GetBacktrace())
  11. {
  12. this->Makefile = mf;
  13. this->OldStyle = true;
  14. }
  15. cmTest::~cmTest() = default;
  16. cmListFileBacktrace const& cmTest::GetBacktrace() const
  17. {
  18. return this->Backtrace;
  19. }
  20. void cmTest::SetName(const std::string& name)
  21. {
  22. this->Name = name;
  23. }
  24. void cmTest::SetCommand(std::vector<std::string> const& command)
  25. {
  26. this->Command = command;
  27. }
  28. const char* cmTest::GetProperty(const std::string& prop) const
  29. {
  30. cmProp retVal = this->Properties.GetPropertyValue(prop);
  31. if (!retVal) {
  32. const bool chain =
  33. this->Makefile->GetState()->IsPropertyChained(prop, cmProperty::TEST);
  34. if (chain) {
  35. if (cmProp p = this->Makefile->GetProperty(prop, chain)) {
  36. return p->c_str();
  37. }
  38. }
  39. return nullptr;
  40. }
  41. return retVal->c_str();
  42. }
  43. bool cmTest::GetPropertyAsBool(const std::string& prop) const
  44. {
  45. return cmIsOn(this->GetProperty(prop));
  46. }
  47. void cmTest::SetProperty(const std::string& prop, const char* value)
  48. {
  49. this->Properties.SetProperty(prop, value);
  50. }
  51. void cmTest::AppendProperty(const std::string& prop, const std::string& value,
  52. bool asString)
  53. {
  54. this->Properties.AppendProperty(prop, value, asString);
  55. }
  56. bool cmTest::GetCommandExpandLists() const
  57. {
  58. return this->CommandExpandLists;
  59. }
  60. void cmTest::SetCommandExpandLists(bool b)
  61. {
  62. this->CommandExpandLists = b;
  63. }