1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmTest.cxx,v $
6 Date: $Date: 2009-08-11 13:07:28 $
7 Version: $Revision: 1.16 $
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 =========================================================================*/
18 #include "cmSystemTools.h"
21 #include "cmMakefile.h"
23 //----------------------------------------------------------------------------
24 cmTest::cmTest(cmMakefile
* mf
)
27 this->OldStyle
= true;
28 this->Properties
.SetCMakeInstance(mf
->GetCMakeInstance());
29 this->Backtrace
= new cmListFileBacktrace
;
30 this->Makefile
->GetBacktrace(*this->Backtrace
);
33 //----------------------------------------------------------------------------
36 delete this->Backtrace
;
39 //----------------------------------------------------------------------------
40 cmListFileBacktrace
const& cmTest::GetBacktrace() const
42 return *this->Backtrace
;
45 //----------------------------------------------------------------------------
46 void cmTest::SetName(const char* name
)
55 //----------------------------------------------------------------------------
56 void cmTest::SetCommand(std::vector
<std::string
> const& command
)
58 this->Command
= command
;
61 //----------------------------------------------------------------------------
62 const char *cmTest::GetProperty(const char* prop
) const
66 this->Properties
.GetPropertyValue(prop
, cmProperty::TEST
, chain
);
69 return this->Makefile
->GetProperty(prop
,cmProperty::TEST
);
74 //----------------------------------------------------------------------------
75 bool cmTest::GetPropertyAsBool(const char* prop
) const
77 return cmSystemTools::IsOn(this->GetProperty(prop
));
80 //----------------------------------------------------------------------------
81 void cmTest::SetProperty(const char* prop
, const char* value
)
88 this->Properties
.SetProperty(prop
, value
, cmProperty::TEST
);
91 //----------------------------------------------------------------------------
92 void cmTest::AppendProperty(const char* prop
, const char* value
)
98 this->Properties
.AppendProperty(prop
, value
, cmProperty::TEST
);
101 //----------------------------------------------------------------------------
102 void cmTest::DefineProperties(cmake
*cm
)
105 ("ENVIRONMENT", cmProperty::TEST
,
106 "Specify environment variables that should be defined for running "
108 "If set to a list of environment variables and values of the form "
109 "MYVAR=value those environment variables will be defined while "
110 "running the test. The environment is restored to its previous state "
111 "after the test is done.");
114 ("FAIL_REGULAR_EXPRESSION", cmProperty::TEST
,
115 "If the output matches this regular expression the test will fail.",
116 "If set, if the output matches one of "
117 "specified regular expressions, the test will fail."
118 "For example: PASS_REGULAR_EXPRESSION \"[^a-z]Error;ERROR;Failed\"");
121 ("LABELS", cmProperty::TEST
,
122 "Specify a list of text labels associated with a test.",
123 "The list is reported in dashboard submissions.");
126 ("MEASUREMENT", cmProperty::TEST
,
127 "Specify a CDASH measurement and value to be reported for a test.",
128 "If set to a name then that name will be reported to CDASH as a "
129 "named measurement with a value of 1. You may also specify a value "
130 "by setting MEASUREMENT to \"measurement=value\".");
133 ("PASS_REGULAR_EXPRESSION", cmProperty::TEST
,
134 "The output must match this regular expression for the test to pass.",
135 "If set, the test output will be checked "
136 "against the specified regular expressions and at least one of the"
137 " regular expressions has to match, otherwise the test will fail.");
140 ("TIMEOUT", cmProperty::TEST
,
141 "How many seconds to allow for this test.",
142 "This property if set will limit a test to not take more than "
143 "the specified number of seconds to run. If it exceeds that the "
144 "test process will be killed and ctest will move to the next test. "
145 "This setting takes precedence over "
146 "CTEST_TESTING_TIMEOUT.");
149 ("WILL_FAIL", cmProperty::TEST
,
150 "If set to true, this will invert the pass/fail flag of the test.",
151 "This property can be used for tests that are expected to fail and "
152 "return a non zero return code.");