2009-09-28 15:43:28 +00:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2005-04-24 19:59:51 +00:00
|
|
|
|
2009-09-28 15:43:28 +00:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2005-04-24 19:59:51 +00:00
|
|
|
|
2009-09-28 15:43:28 +00:00
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
2005-04-24 19:59:51 +00:00
|
|
|
#include "cmTest.h"
|
|
|
|
#include "cmSystemTools.h"
|
|
|
|
|
2006-12-07 14:45:32 +00:00
|
|
|
#include "cmake.h"
|
|
|
|
#include "cmMakefile.h"
|
2005-04-24 19:59:51 +00:00
|
|
|
|
2009-04-03 15:41:33 +00:00
|
|
|
//----------------------------------------------------------------------------
|
2009-08-11 13:07:28 +00:00
|
|
|
cmTest::cmTest(cmMakefile* mf)
|
2005-04-24 19:59:51 +00:00
|
|
|
{
|
2009-08-11 13:07:28 +00:00
|
|
|
this->Makefile = mf;
|
2009-03-16 14:51:30 +00:00
|
|
|
this->OldStyle = true;
|
2009-08-11 13:07:28 +00:00
|
|
|
this->Properties.SetCMakeInstance(mf->GetCMakeInstance());
|
|
|
|
this->Backtrace = new cmListFileBacktrace;
|
|
|
|
this->Makefile->GetBacktrace(*this->Backtrace);
|
2005-04-24 19:59:51 +00:00
|
|
|
}
|
|
|
|
|
2009-04-03 15:41:33 +00:00
|
|
|
//----------------------------------------------------------------------------
|
2005-04-24 19:59:51 +00:00
|
|
|
cmTest::~cmTest()
|
|
|
|
{
|
2009-08-11 13:07:28 +00:00
|
|
|
delete this->Backtrace;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
cmListFileBacktrace const& cmTest::GetBacktrace() const
|
|
|
|
{
|
|
|
|
return *this->Backtrace;
|
2005-04-24 19:59:51 +00:00
|
|
|
}
|
|
|
|
|
2009-04-03 15:41:33 +00:00
|
|
|
//----------------------------------------------------------------------------
|
2005-04-24 19:59:51 +00:00
|
|
|
void cmTest::SetName(const char* name)
|
|
|
|
{
|
|
|
|
if ( !name )
|
|
|
|
{
|
|
|
|
name = "";
|
|
|
|
}
|
2006-03-15 16:02:08 +00:00
|
|
|
this->Name = name;
|
2005-04-24 19:59:51 +00:00
|
|
|
}
|
|
|
|
|
2009-04-03 15:41:33 +00:00
|
|
|
//----------------------------------------------------------------------------
|
2009-03-16 14:42:40 +00:00
|
|
|
void cmTest::SetCommand(std::vector<std::string> const& command)
|
2005-04-24 19:59:51 +00:00
|
|
|
{
|
2006-03-15 16:02:08 +00:00
|
|
|
this->Command = command;
|
2005-04-24 19:59:51 +00:00
|
|
|
}
|
|
|
|
|
2009-04-03 15:41:33 +00:00
|
|
|
//----------------------------------------------------------------------------
|
2005-07-31 15:51:42 +00:00
|
|
|
const char *cmTest::GetProperty(const char* prop) const
|
|
|
|
{
|
2006-12-07 14:45:32 +00:00
|
|
|
bool chain = false;
|
|
|
|
const char *retVal =
|
|
|
|
this->Properties.GetPropertyValue(prop, cmProperty::TEST, chain);
|
|
|
|
if (chain)
|
2005-07-31 15:51:42 +00:00
|
|
|
{
|
2006-12-07 14:45:32 +00:00
|
|
|
return this->Makefile->GetProperty(prop,cmProperty::TEST);
|
2005-07-31 15:51:42 +00:00
|
|
|
}
|
2006-12-07 15:22:19 +00:00
|
|
|
return retVal;
|
2005-07-31 15:51:42 +00:00
|
|
|
}
|
|
|
|
|
2009-04-03 15:41:33 +00:00
|
|
|
//----------------------------------------------------------------------------
|
2005-07-31 15:51:42 +00:00
|
|
|
bool cmTest::GetPropertyAsBool(const char* prop) const
|
|
|
|
{
|
2006-12-07 14:45:32 +00:00
|
|
|
return cmSystemTools::IsOn(this->GetProperty(prop));
|
2005-07-31 15:51:42 +00:00
|
|
|
}
|
|
|
|
|
2009-04-03 15:41:33 +00:00
|
|
|
//----------------------------------------------------------------------------
|
2005-07-31 15:51:42 +00:00
|
|
|
void cmTest::SetProperty(const char* prop, const char* value)
|
|
|
|
{
|
|
|
|
if (!prop)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2006-12-07 14:45:32 +00:00
|
|
|
|
|
|
|
this->Properties.SetProperty(prop, value, cmProperty::TEST);
|
|
|
|
}
|
|
|
|
|
2008-01-17 23:13:55 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmTest::AppendProperty(const char* prop, const char* value)
|
|
|
|
{
|
|
|
|
if (!prop)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this->Properties.AppendProperty(prop, value, cmProperty::TEST);
|
|
|
|
}
|
|
|
|
|
2009-04-03 15:41:33 +00:00
|
|
|
//----------------------------------------------------------------------------
|
2006-12-07 14:45:32 +00:00
|
|
|
void cmTest::DefineProperties(cmake *cm)
|
|
|
|
{
|
2009-12-17 19:34:47 +00:00
|
|
|
cm->DefineProperty
|
|
|
|
("ATTACHED_FILES", cmProperty::TEST,
|
|
|
|
"Attach a list of files to a dashboard submission.",
|
|
|
|
"Set this property to a list of files that will be encoded and "
|
|
|
|
"submitted to the dashboard as an addition to the test result.");
|
|
|
|
|
|
|
|
cm->DefineProperty
|
|
|
|
("ATTACHED_FILES_ON_FAIL", cmProperty::TEST,
|
|
|
|
"Attach a list of files to a dashboard submission if the test fails.",
|
|
|
|
"Same as ATTACHED_FILES, but these files will only be included if the "
|
|
|
|
"test does not pass.");
|
|
|
|
|
|
|
|
cm->DefineProperty
|
|
|
|
("COST", cmProperty::TEST,
|
|
|
|
"Set this to a floating point value. Tests in a test set will be "
|
|
|
|
"run in descending order of cost.", "This property describes the cost "
|
|
|
|
"of a test. You can explicitly set this value; tests with higher COST "
|
|
|
|
"values will run first.");
|
|
|
|
|
|
|
|
cm->DefineProperty
|
|
|
|
("DEPENDS", cmProperty::TEST,
|
|
|
|
"Specifies that this test should only be run after the specified "
|
|
|
|
"list of tests.",
|
|
|
|
"Set this to a list of tests that must finish before this test is run.");
|
|
|
|
|
2006-12-07 14:45:32 +00:00
|
|
|
cm->DefineProperty
|
2009-04-03 15:41:33 +00:00
|
|
|
("ENVIRONMENT", cmProperty::TEST,
|
|
|
|
"Specify environment variables that should be defined for running "
|
|
|
|
"a test.",
|
|
|
|
"If set to a list of environment variables and values of the form "
|
|
|
|
"MYVAR=value those environment variables will be defined while "
|
|
|
|
"running the test. The environment is restored to its previous state "
|
|
|
|
"after the test is done.");
|
|
|
|
|
|
|
|
cm->DefineProperty
|
|
|
|
("FAIL_REGULAR_EXPRESSION", cmProperty::TEST,
|
2008-01-10 03:09:19 +00:00
|
|
|
"If the output matches this regular expression the test will fail.",
|
2006-12-07 14:45:32 +00:00
|
|
|
"If set, if the output matches one of "
|
|
|
|
"specified regular expressions, the test will fail."
|
|
|
|
"For example: PASS_REGULAR_EXPRESSION \"[^a-z]Error;ERROR;Failed\"");
|
|
|
|
|
2009-01-07 15:41:37 +00:00
|
|
|
cm->DefineProperty
|
|
|
|
("LABELS", cmProperty::TEST,
|
|
|
|
"Specify a list of text labels associated with a test.",
|
|
|
|
"The list is reported in dashboard submissions.");
|
|
|
|
|
2010-03-02 20:34:37 +00:00
|
|
|
cm->DefineProperty
|
|
|
|
("RESOURCE_LOCK", cmProperty::TEST,
|
|
|
|
"Specify a list of resources that are locked by this test.",
|
|
|
|
"If multiple tests specify the same resource lock, they are guaranteed "
|
|
|
|
"not to run concurrently.");
|
|
|
|
|
2006-12-07 14:45:32 +00:00
|
|
|
cm->DefineProperty
|
|
|
|
("MEASUREMENT", cmProperty::TEST,
|
2009-08-04 17:16:30 +00:00
|
|
|
"Specify a CDASH measurement and value to be reported for a test.",
|
|
|
|
"If set to a name then that name will be reported to CDASH as a "
|
2006-12-07 14:45:32 +00:00
|
|
|
"named measurement with a value of 1. You may also specify a value "
|
|
|
|
"by setting MEASUREMENT to \"measurement=value\".");
|
|
|
|
|
|
|
|
cm->DefineProperty
|
|
|
|
("PASS_REGULAR_EXPRESSION", cmProperty::TEST,
|
|
|
|
"The output must match this regular expression for the test to pass.",
|
|
|
|
"If set, the test output will be checked "
|
|
|
|
"against the specified regular expressions and at least one of the"
|
|
|
|
" regular expressions has to match, otherwise the test will fail.");
|
|
|
|
|
2009-12-17 19:34:47 +00:00
|
|
|
cm->DefineProperty
|
|
|
|
("PROCESSORS", cmProperty::TEST,
|
|
|
|
"How many process slots this test requires",
|
|
|
|
"Denotes the number of processors that this test will require. This is "
|
|
|
|
"typically used for MPI tests, and should be used in conjunction with "
|
|
|
|
"the ctest_test PARALLEL_LEVEL option.");
|
|
|
|
|
|
|
|
cm->DefineProperty
|
|
|
|
("REQUIRED_FILES", cmProperty::TEST,
|
|
|
|
"List of files required to run the test.",
|
|
|
|
"If set to a list of files, the test will not be run unless all of the "
|
|
|
|
"files exist.");
|
|
|
|
|
|
|
|
cm->DefineProperty
|
|
|
|
("RUN_SERIAL", cmProperty::TEST,
|
|
|
|
"Do not run this test in parallel with any other test.",
|
|
|
|
"Use this option in conjunction with the ctest_test PARALLEL_LEVEL "
|
|
|
|
"option to specify that this test should not be run in parallel with "
|
|
|
|
"any other tests.");
|
|
|
|
|
2007-01-25 16:16:16 +00:00
|
|
|
cm->DefineProperty
|
|
|
|
("TIMEOUT", cmProperty::TEST,
|
|
|
|
"How many seconds to allow for this test.",
|
2008-01-10 03:09:19 +00:00
|
|
|
"This property if set will limit a test to not take more than "
|
2007-01-25 16:16:16 +00:00
|
|
|
"the specified number of seconds to run. If it exceeds that the "
|
|
|
|
"test process will be killed and ctest will move to the next test. "
|
2009-08-04 17:16:30 +00:00
|
|
|
"This setting takes precedence over "
|
2008-01-10 03:09:19 +00:00
|
|
|
"CTEST_TESTING_TIMEOUT.");
|
2007-01-25 16:16:16 +00:00
|
|
|
|
2006-12-07 14:45:32 +00:00
|
|
|
cm->DefineProperty
|
|
|
|
("WILL_FAIL", cmProperty::TEST,
|
|
|
|
"If set to true, this will invert the pass/fail flag of the test.",
|
|
|
|
"This property can be used for tests that are expected to fail and "
|
|
|
|
"return a non zero return code.");
|
2010-10-26 10:06:15 +00:00
|
|
|
|
|
|
|
cm->DefineProperty
|
|
|
|
("WORKING_DIRECTORY", cmProperty::TEST,
|
|
|
|
"The directory from which the test executable will be called.",
|
|
|
|
"If this is not set it is called from the directory the test executable "
|
|
|
|
"is located in.");
|
2006-12-07 14:45:32 +00:00
|
|
|
}
|