1 /*============================================================================
2 CMake - Cross Platform Makefile Generator
3 Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
5 Distributed under the OSI-approved BSD License (the "License");
6 see accompanying file Copyright.txt for details.
8 This software is distributed WITHOUT ANY WARRANTY; without even the
9 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the License for more information.
11 ============================================================================*/
13 #include "cmSystemTools.h"
16 #include "cmMakefile.h"
18 //----------------------------------------------------------------------------
19 cmTest::cmTest(cmMakefile* mf)
22 this->OldStyle = true;
23 this->Properties.SetCMakeInstance(mf->GetCMakeInstance());
24 this->Backtrace = new cmListFileBacktrace;
25 this->Makefile->GetBacktrace(*this->Backtrace);
28 //----------------------------------------------------------------------------
31 delete this->Backtrace;
34 //----------------------------------------------------------------------------
35 cmListFileBacktrace const& cmTest::GetBacktrace() const
37 return *this->Backtrace;
40 //----------------------------------------------------------------------------
41 void cmTest::SetName(const char* name)
50 //----------------------------------------------------------------------------
51 void cmTest::SetCommand(std::vector<std::string> const& command)
53 this->Command = command;
56 //----------------------------------------------------------------------------
57 const char *cmTest::GetProperty(const char* prop) const
61 this->Properties.GetPropertyValue(prop, cmProperty::TEST, chain);
64 return this->Makefile->GetProperty(prop,cmProperty::TEST);
69 //----------------------------------------------------------------------------
70 bool cmTest::GetPropertyAsBool(const char* prop) const
72 return cmSystemTools::IsOn(this->GetProperty(prop));
75 //----------------------------------------------------------------------------
76 void cmTest::SetProperty(const char* prop, const char* value)
83 this->Properties.SetProperty(prop, value, cmProperty::TEST);
86 //----------------------------------------------------------------------------
87 void cmTest::AppendProperty(const char* prop, const char* value, bool asString)
93 this->Properties.AppendProperty(prop, value, cmProperty::TEST, asString);
96 //----------------------------------------------------------------------------
97 void cmTest::DefineProperties(cmake *cm)
100 ("ATTACHED_FILES", cmProperty::TEST,
101 "Attach a list of files to a dashboard submission.",
102 "Set this property to a list of files that will be encoded and "
103 "submitted to the dashboard as an addition to the test result.");
106 ("ATTACHED_FILES_ON_FAIL", cmProperty::TEST,
107 "Attach a list of files to a dashboard submission if the test fails.",
108 "Same as ATTACHED_FILES, but these files will only be included if the "
109 "test does not pass.");
112 ("COST", cmProperty::TEST,
113 "Set this to a floating point value. Tests in a test set will be "
114 "run in descending order of cost.", "This property describes the cost "
115 "of a test. You can explicitly set this value; tests with higher COST "
116 "values will run first.");
119 ("DEPENDS", cmProperty::TEST,
120 "Specifies that this test should only be run after the specified "
122 "Set this to a list of tests that must finish before this test is run.");
125 ("ENVIRONMENT", cmProperty::TEST,
126 "Specify environment variables that should be defined for running "
128 "If set to a list of environment variables and values of the form "
129 "MYVAR=value those environment variables will be defined while "
130 "running the test. The environment is restored to its previous state "
131 "after the test is done.");
134 ("FAIL_REGULAR_EXPRESSION", cmProperty::TEST,
135 "If the output matches this regular expression the test will fail.",
136 "If set, if the output matches one of "
137 "specified regular expressions, the test will fail."
138 "For example: FAIL_REGULAR_EXPRESSION \"[^a-z]Error;ERROR;Failed\"");
141 ("LABELS", cmProperty::TEST,
142 "Specify a list of text labels associated with a test.",
143 "The list is reported in dashboard submissions.");
146 ("RESOURCE_LOCK", cmProperty::TEST,
147 "Specify a list of resources that are locked by this test.",
148 "If multiple tests specify the same resource lock, they are guaranteed "
149 "not to run concurrently.");
152 ("MEASUREMENT", cmProperty::TEST,
153 "Specify a CDASH measurement and value to be reported for a test.",
154 "If set to a name then that name will be reported to CDASH as a "
155 "named measurement with a value of 1. You may also specify a value "
156 "by setting MEASUREMENT to \"measurement=value\".");
159 ("PASS_REGULAR_EXPRESSION", cmProperty::TEST,
160 "The output must match this regular expression for the test to pass.",
161 "If set, the test output will be checked "
162 "against the specified regular expressions and at least one of the"
163 " regular expressions has to match, otherwise the test will fail.");
166 ("PROCESSORS", cmProperty::TEST,
167 "How many process slots this test requires",
168 "Denotes the number of processors that this test will require. This is "
169 "typically used for MPI tests, and should be used in conjunction with "
170 "the ctest_test PARALLEL_LEVEL option.");
173 ("REQUIRED_FILES", cmProperty::TEST,
174 "List of files required to run the test.",
175 "If set to a list of files, the test will not be run unless all of the "
179 ("RUN_SERIAL", cmProperty::TEST,
180 "Do not run this test in parallel with any other test.",
181 "Use this option in conjunction with the ctest_test PARALLEL_LEVEL "
182 "option to specify that this test should not be run in parallel with "
186 ("TIMEOUT", cmProperty::TEST,
187 "How many seconds to allow for this test.",
188 "This property if set will limit a test to not take more than "
189 "the specified number of seconds to run. If it exceeds that the "
190 "test process will be killed and ctest will move to the next test. "
191 "This setting takes precedence over "
192 "CTEST_TESTING_TIMEOUT.");
195 ("WILL_FAIL", cmProperty::TEST,
196 "If set to true, this will invert the pass/fail flag of the test.",
197 "This property can be used for tests that are expected to fail and "
198 "return a non zero return code.");
201 ("WORKING_DIRECTORY", cmProperty::TEST,
202 "The directory from which the test executable will be called.",
203 "If this is not set it is called from the directory the test executable "