cmTest.cxx 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. this->OldStyle = true;
  21. }
  22. cmTest::~cmTest()
  23. {
  24. }
  25. void cmTest::SetName(const char* name)
  26. {
  27. if ( !name )
  28. {
  29. name = "";
  30. }
  31. this->Name = name;
  32. }
  33. void cmTest::SetCommand(std::vector<std::string> const& command)
  34. {
  35. this->Command = command;
  36. }
  37. const char *cmTest::GetProperty(const char* prop) const
  38. {
  39. bool chain = false;
  40. const char *retVal =
  41. this->Properties.GetPropertyValue(prop, cmProperty::TEST, chain);
  42. if (chain)
  43. {
  44. return this->Makefile->GetProperty(prop,cmProperty::TEST);
  45. }
  46. return retVal;
  47. }
  48. bool cmTest::GetPropertyAsBool(const char* prop) const
  49. {
  50. return cmSystemTools::IsOn(this->GetProperty(prop));
  51. }
  52. void cmTest::SetProperty(const char* prop, const char* value)
  53. {
  54. if (!prop)
  55. {
  56. return;
  57. }
  58. this->Properties.SetProperty(prop, value, cmProperty::TEST);
  59. }
  60. //----------------------------------------------------------------------------
  61. void cmTest::AppendProperty(const char* prop, const char* value)
  62. {
  63. if (!prop)
  64. {
  65. return;
  66. }
  67. this->Properties.AppendProperty(prop, value, cmProperty::TEST);
  68. }
  69. //----------------------------------------------------------------------------
  70. void cmTest::SetMakefile(cmMakefile* mf)
  71. {
  72. // Set our makefile.
  73. this->Makefile = mf;
  74. this->Properties.SetCMakeInstance(mf->GetCMakeInstance());
  75. }
  76. // define properties
  77. void cmTest::DefineProperties(cmake *cm)
  78. {
  79. // define properties
  80. cm->DefineProperty
  81. ("FAIL_REGULAR_EXPRESSION", cmProperty::TEST,
  82. "If the output matches this regular expression the test will fail.",
  83. "If set, if the output matches one of "
  84. "specified regular expressions, the test will fail."
  85. "For example: PASS_REGULAR_EXPRESSION \"[^a-z]Error;ERROR;Failed\"");
  86. cm->DefineProperty
  87. ("LABELS", cmProperty::TEST,
  88. "Specify a list of text labels associated with a test.",
  89. "The list is reported in dashboard submissions.");
  90. cm->DefineProperty
  91. ("MEASUREMENT", cmProperty::TEST,
  92. "Specify a DART measurement and value to be reported for a test.",
  93. "If set to a name then that name will be reported to DART as a "
  94. "named measurement with a value of 1. You may also specify a value "
  95. "by setting MEASUREMENT to \"measurement=value\".");
  96. cm->DefineProperty
  97. ("PASS_REGULAR_EXPRESSION", cmProperty::TEST,
  98. "The output must match this regular expression for the test to pass.",
  99. "If set, the test output will be checked "
  100. "against the specified regular expressions and at least one of the"
  101. " regular expressions has to match, otherwise the test will fail.");
  102. cm->DefineProperty
  103. ("TIMEOUT", cmProperty::TEST,
  104. "How many seconds to allow for this test.",
  105. "This property if set will limit a test to not take more than "
  106. "the specified number of seconds to run. If it exceeds that the "
  107. "test process will be killed and ctest will move to the next test. "
  108. "This setting takes precedence over DART_TESTING_TIMEOUT and "
  109. "CTEST_TESTING_TIMEOUT.");
  110. cm->DefineProperty
  111. ("WILL_FAIL", cmProperty::TEST,
  112. "If set to true, this will invert the pass/fail flag of the test.",
  113. "This property can be used for tests that are expected to fail and "
  114. "return a non zero return code.");
  115. }