Initial commit.
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / cmTest.cxx
blob4734fa909f5713f4e465360597845eed230c802a
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmTest.cxx,v $
5 Language: C++
6 Date: $Date: 2008/01/17 23:13:55 $
7 Version: $Revision: 1.9 $
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;
28 cmTest::~cmTest()
32 void cmTest::SetName(const char* name)
34 if ( !name )
36 name = "";
38 this->Name = name;
41 void cmTest::SetCommand(const char* command)
43 if ( !command )
45 command = "";
47 this->Command = command;
48 cmSystemTools::ConvertToUnixSlashes(this->Command);
51 void cmTest::SetArguments(const std::vector<cmStdString>& args)
53 this->Args = args;
56 const char *cmTest::GetProperty(const char* prop) const
58 bool chain = false;
59 const char *retVal =
60 this->Properties.GetPropertyValue(prop, cmProperty::TEST, chain);
61 if (chain)
63 return this->Makefile->GetProperty(prop,cmProperty::TEST);
65 return retVal;
68 bool cmTest::GetPropertyAsBool(const char* prop) const
70 return cmSystemTools::IsOn(this->GetProperty(prop));
73 void cmTest::SetProperty(const char* prop, const char* value)
75 if (!prop)
77 return;
79 if (!value)
81 value = "NOTFOUND";
84 this->Properties.SetProperty(prop, value, cmProperty::TEST);
87 //----------------------------------------------------------------------------
88 void cmTest::AppendProperty(const char* prop, const char* value)
90 if (!prop)
92 return;
94 this->Properties.AppendProperty(prop, value, cmProperty::TEST);
97 //----------------------------------------------------------------------------
98 void cmTest::SetMakefile(cmMakefile* mf)
100 // Set our makefile.
101 this->Makefile = mf;
102 this->Properties.SetCMakeInstance(mf->GetCMakeInstance());
105 // define properties
106 void cmTest::DefineProperties(cmake *cm)
108 // define properties
109 cm->DefineProperty
110 ("FAIL_REGULAR_EXPRESSION", cmProperty::TEST,
111 "If the output matches this regular expression the test will fail.",
112 "If set, if the output matches one of "
113 "specified regular expressions, the test will fail."
114 "For example: PASS_REGULAR_EXPRESSION \"[^a-z]Error;ERROR;Failed\"");
116 cm->DefineProperty
117 ("MEASUREMENT", cmProperty::TEST,
118 "Specify a DART measurement and value to be reported for a test.",
119 "If set to a name then that name will be reported to DART as a "
120 "named measurement with a value of 1. You may also specify a value "
121 "by setting MEASUREMENT to \"measurement=value\".");
123 cm->DefineProperty
124 ("PASS_REGULAR_EXPRESSION", cmProperty::TEST,
125 "The output must match this regular expression for the test to pass.",
126 "If set, the test output will be checked "
127 "against the specified regular expressions and at least one of the"
128 " regular expressions has to match, otherwise the test will fail.");
130 cm->DefineProperty
131 ("TIMEOUT", cmProperty::TEST,
132 "How many seconds to allow for this test.",
133 "This property if set will limit a test to not take more than "
134 "the specified number of seconds to run. If it exceeds that the "
135 "test process will be killed and ctest will move to the next test. "
136 "This setting takes precedence over DART_TESTING_TIMEOUT and "
137 "CTEST_TESTING_TIMEOUT.");
139 cm->DefineProperty
140 ("WILL_FAIL", cmProperty::TEST,
141 "If set to true, this will invert the pass/fail flag of the test.",
142 "This property can be used for tests that are expected to fail and "
143 "return a non zero return code.");