cmTest.cxx 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #include "cmTest.h"
  14. #include "cmSystemTools.h"
  15. #include "cmake.h"
  16. #include "cmMakefile.h"
  17. cmTest::cmTest()
  18. {
  19. this->Makefile = 0;
  20. }
  21. cmTest::~cmTest()
  22. {
  23. }
  24. void cmTest::SetName(const char* name)
  25. {
  26. if ( !name )
  27. {
  28. name = "";
  29. }
  30. this->Name = name;
  31. }
  32. void cmTest::SetCommand(std::vector<std::string> const& command)
  33. {
  34. this->Command = command;
  35. }
  36. const char *cmTest::GetProperty(const char* prop) const
  37. {
  38. bool chain = false;
  39. const char *retVal =
  40. this->Properties.GetPropertyValue(prop, cmProperty::TEST, chain);
  41. if (chain)
  42. {
  43. return this->Makefile->GetProperty(prop,cmProperty::TEST);
  44. }
  45. return retVal;
  46. }
  47. bool cmTest::GetPropertyAsBool(const char* prop) const
  48. {
  49. return cmSystemTools::IsOn(this->GetProperty(prop));
  50. }
  51. void cmTest::SetProperty(const char* prop, const char* value)
  52. {
  53. if (!prop)
  54. {
  55. return;
  56. }
  57. this->Properties.SetProperty(prop, value, cmProperty::TEST);
  58. }
  59. //----------------------------------------------------------------------------
  60. void cmTest::AppendProperty(const char* prop, const char* value)
  61. {
  62. if (!prop)
  63. {
  64. return;
  65. }
  66. this->Properties.AppendProperty(prop, value, cmProperty::TEST);
  67. }
  68. //----------------------------------------------------------------------------
  69. void cmTest::SetMakefile(cmMakefile* mf)
  70. {
  71. // Set our makefile.
  72. this->Makefile = mf;
  73. this->Properties.SetCMakeInstance(mf->GetCMakeInstance());
  74. }
  75. // define properties
  76. void cmTest::DefineProperties(cmake *cm)
  77. {
  78. // define properties
  79. cm->DefineProperty
  80. ("FAIL_REGULAR_EXPRESSION", cmProperty::TEST,
  81. "If the output matches this regular expression the test will fail.",
  82. "If set, if the output matches one of "
  83. "specified regular expressions, the test will fail."
  84. "For example: PASS_REGULAR_EXPRESSION \"[^a-z]Error;ERROR;Failed\"");
  85. cm->DefineProperty
  86. ("LABELS", cmProperty::TEST,
  87. "Specify a list of text labels associated with a test.",
  88. "The list is reported in dashboard submissions.");
  89. cm->DefineProperty
  90. ("MEASUREMENT", cmProperty::TEST,
  91. "Specify a DART measurement and value to be reported for a test.",
  92. "If set to a name then that name will be reported to DART as a "
  93. "named measurement with a value of 1. You may also specify a value "
  94. "by setting MEASUREMENT to \"measurement=value\".");
  95. cm->DefineProperty
  96. ("PASS_REGULAR_EXPRESSION", cmProperty::TEST,
  97. "The output must match this regular expression for the test to pass.",
  98. "If set, the test output will be checked "
  99. "against the specified regular expressions and at least one of the"
  100. " regular expressions has to match, otherwise the test will fail.");
  101. cm->DefineProperty
  102. ("TIMEOUT", cmProperty::TEST,
  103. "How many seconds to allow for this test.",
  104. "This property if set will limit a test to not take more than "
  105. "the specified number of seconds to run. If it exceeds that the "
  106. "test process will be killed and ctest will move to the next test. "
  107. "This setting takes precedence over DART_TESTING_TIMEOUT and "
  108. "CTEST_TESTING_TIMEOUT.");
  109. cm->DefineProperty
  110. ("WILL_FAIL", cmProperty::TEST,
  111. "If set to true, this will invert the pass/fail flag of the test.",
  112. "This property can be used for tests that are expected to fail and "
  113. "return a non zero return code.");
  114. }