You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

134 lines
3.7 KiB

  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(const char* command)
  33. {
  34. if ( !command )
  35. {
  36. command = "";
  37. }
  38. this->Command = command;
  39. cmSystemTools::ConvertToUnixSlashes(this->Command);
  40. }
  41. void cmTest::SetArguments(const std::vector<cmStdString>& args)
  42. {
  43. this->Args = args;
  44. }
  45. const char *cmTest::GetProperty(const char* prop) const
  46. {
  47. bool chain = false;
  48. const char *retVal =
  49. this->Properties.GetPropertyValue(prop, cmProperty::TEST, chain);
  50. if (chain)
  51. {
  52. return this->Makefile->GetProperty(prop,cmProperty::TEST);
  53. }
  54. return retVal;
  55. }
  56. bool cmTest::GetPropertyAsBool(const char* prop) const
  57. {
  58. return cmSystemTools::IsOn(this->GetProperty(prop));
  59. }
  60. void cmTest::SetProperty(const char* prop, const char* value)
  61. {
  62. if (!prop)
  63. {
  64. return;
  65. }
  66. if (!value)
  67. {
  68. value = "NOTFOUND";
  69. }
  70. this->Properties.SetProperty(prop, value, cmProperty::TEST);
  71. }
  72. //----------------------------------------------------------------------------
  73. void cmTest::SetMakefile(cmMakefile* mf)
  74. {
  75. // Set our makefile.
  76. this->Makefile = mf;
  77. this->Properties.SetCMakeInstance(mf->GetCMakeInstance());
  78. }
  79. // define properties
  80. void cmTest::DefineProperties(cmake *cm)
  81. {
  82. // define properties
  83. cm->DefineProperty
  84. ("FAIL_REGULAR_EXPRESSION", cmProperty::TEST,
  85. "If the output matches this regular expression tes test will fail.",
  86. "If set, if the output matches one of "
  87. "specified regular expressions, the test will fail."
  88. "For example: PASS_REGULAR_EXPRESSION \"[^a-z]Error;ERROR;Failed\"");
  89. cm->DefineProperty
  90. ("MEASUREMENT", cmProperty::TEST,
  91. "Specify a DART meansurement 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 nto 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_TIMOUT.");
  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. }