cmTest.cxx 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 "cmValue.h"
  8. cmTest::cmTest(cmMakefile* mf)
  9. : Backtrace(mf->GetBacktrace())
  10. {
  11. this->Makefile = mf;
  12. this->OldStyle = true;
  13. }
  14. cmTest::~cmTest() = default;
  15. cmListFileBacktrace const& cmTest::GetBacktrace() const
  16. {
  17. return this->Backtrace;
  18. }
  19. void cmTest::SetName(const std::string& name)
  20. {
  21. this->Name = name;
  22. }
  23. void cmTest::SetCommand(std::vector<std::string> const& command)
  24. {
  25. this->Command = command;
  26. }
  27. cmValue cmTest::GetProperty(const std::string& prop) const
  28. {
  29. cmValue retVal = this->Properties.GetPropertyValue(prop);
  30. if (!retVal) {
  31. const bool chain =
  32. this->Makefile->GetState()->IsPropertyChained(prop, cmProperty::TEST);
  33. if (chain) {
  34. if (cmValue p = this->Makefile->GetProperty(prop, chain)) {
  35. return p;
  36. }
  37. }
  38. return nullptr;
  39. }
  40. return retVal;
  41. }
  42. bool cmTest::GetPropertyAsBool(const std::string& prop) const
  43. {
  44. return cmIsOn(this->GetProperty(prop));
  45. }
  46. void cmTest::SetProperty(const std::string& prop, cmValue value)
  47. {
  48. this->Properties.SetProperty(prop, value);
  49. }
  50. void cmTest::AppendProperty(const std::string& prop, const std::string& value,
  51. bool asString)
  52. {
  53. this->Properties.AppendProperty(prop, value, asString);
  54. }
  55. bool cmTest::GetCommandExpandLists() const
  56. {
  57. return this->CommandExpandLists;
  58. }
  59. void cmTest::SetCommandExpandLists(bool b)
  60. {
  61. this->CommandExpandLists = b;
  62. }