Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / cmTest.cxx
blob4e3938b770f917c3d0f78bb716ad89816b07a38b
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmTest.cxx,v $
5 Language: C++
6 Date: $Date: 2009-03-16 14:51:14 $
7 Version: $Revision: 1.13 $
9 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
17 #include "cmTest.h"
18 #include "cmSystemTools.h"
20 #include "cmake.h"
21 #include "cmMakefile.h"
23 cmTest::cmTest()
25 this->Makefile = 0;
26 this->OldStyle = true;
29 cmTest::~cmTest()
33 void cmTest::SetName(const char* name)
35 if ( !name )
37 name = "";
39 this->Name = name;
42 void cmTest::SetCommand(std::vector<std::string> const& command)
44 this->Command = command;
47 const char *cmTest::GetProperty(const char* prop) const
49 bool chain = false;
50 const char *retVal =
51 this->Properties.GetPropertyValue(prop, cmProperty::TEST, chain);
52 if (chain)
54 return this->Makefile->GetProperty(prop,cmProperty::TEST);
56 return retVal;
59 bool cmTest::GetPropertyAsBool(const char* prop) const
61 return cmSystemTools::IsOn(this->GetProperty(prop));
64 void cmTest::SetProperty(const char* prop, const char* value)
66 if (!prop)
68 return;
71 this->Properties.SetProperty(prop, value, cmProperty::TEST);
74 //----------------------------------------------------------------------------
75 void cmTest::AppendProperty(const char* prop, const char* value)
77 if (!prop)
79 return;
81 this->Properties.AppendProperty(prop, value, cmProperty::TEST);
84 //----------------------------------------------------------------------------
85 void cmTest::SetMakefile(cmMakefile* mf)
87 // Set our makefile.
88 this->Makefile = mf;
89 this->Properties.SetCMakeInstance(mf->GetCMakeInstance());
92 // define properties
93 void cmTest::DefineProperties(cmake *cm)
95 // define properties
96 cm->DefineProperty
97 ("FAIL_REGULAR_EXPRESSION", cmProperty::TEST,
98 "If the output matches this regular expression the test will fail.",
99 "If set, if the output matches one of "
100 "specified regular expressions, the test will fail."
101 "For example: PASS_REGULAR_EXPRESSION \"[^a-z]Error;ERROR;Failed\"");
103 cm->DefineProperty
104 ("LABELS", cmProperty::TEST,
105 "Specify a list of text labels associated with a test.",
106 "The list is reported in dashboard submissions.");
108 cm->DefineProperty
109 ("MEASUREMENT", cmProperty::TEST,
110 "Specify a DART measurement and value to be reported for a test.",
111 "If set to a name then that name will be reported to DART as a "
112 "named measurement with a value of 1. You may also specify a value "
113 "by setting MEASUREMENT to \"measurement=value\".");
115 cm->DefineProperty
116 ("PASS_REGULAR_EXPRESSION", cmProperty::TEST,
117 "The output must match this regular expression for the test to pass.",
118 "If set, the test output will be checked "
119 "against the specified regular expressions and at least one of the"
120 " regular expressions has to match, otherwise the test will fail.");
122 cm->DefineProperty
123 ("TIMEOUT", cmProperty::TEST,
124 "How many seconds to allow for this test.",
125 "This property if set will limit a test to not take more than "
126 "the specified number of seconds to run. If it exceeds that the "
127 "test process will be killed and ctest will move to the next test. "
128 "This setting takes precedence over DART_TESTING_TIMEOUT and "
129 "CTEST_TESTING_TIMEOUT.");
131 cm->DefineProperty
132 ("WILL_FAIL", cmProperty::TEST,
133 "If set to true, this will invert the pass/fail flag of the test.",
134 "This property can be used for tests that are expected to fail and "
135 "return a non zero return code.");