2005-04-24 23:59:51 +04:00
|
|
|
/*=========================================================================
|
|
|
|
|
|
|
|
Program: CMake - Cross-Platform Makefile Generator
|
|
|
|
Module: $RCSfile$
|
|
|
|
Language: C++
|
|
|
|
Date: $Date$
|
|
|
|
Version: $Revision$
|
|
|
|
|
|
|
|
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
|
|
|
|
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
|
|
|
|
|
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even
|
|
|
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
PURPOSE. See the above copyright notices for more information.
|
|
|
|
|
|
|
|
=========================================================================*/
|
|
|
|
#include "cmTest.h"
|
|
|
|
#include "cmSystemTools.h"
|
|
|
|
|
2006-12-07 17:45:32 +03:00
|
|
|
#include "cmake.h"
|
|
|
|
#include "cmMakefile.h"
|
2005-04-24 23:59:51 +04:00
|
|
|
|
|
|
|
cmTest::cmTest()
|
|
|
|
{
|
2006-12-07 17:45:32 +03:00
|
|
|
this->Makefile = 0;
|
2005-04-24 23:59:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
cmTest::~cmTest()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmTest::SetName(const char* name)
|
|
|
|
{
|
|
|
|
if ( !name )
|
|
|
|
{
|
|
|
|
name = "";
|
|
|
|
}
|
2006-03-15 19:02:08 +03:00
|
|
|
this->Name = name;
|
2005-04-24 23:59:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmTest::SetCommand(const char* command)
|
|
|
|
{
|
|
|
|
if ( !command )
|
|
|
|
{
|
|
|
|
command = "";
|
|
|
|
}
|
2006-03-15 19:02:08 +03:00
|
|
|
this->Command = command;
|
2006-04-25 16:34:30 +04:00
|
|
|
cmSystemTools::ConvertToUnixSlashes(this->Command);
|
2005-04-24 23:59:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmTest::SetArguments(const std::vector<cmStdString>& args)
|
|
|
|
{
|
2006-03-15 19:02:08 +03:00
|
|
|
this->Args = args;
|
2005-04-24 23:59:51 +04:00
|
|
|
}
|
|
|
|
|
2005-07-31 19:51:42 +04:00
|
|
|
const char *cmTest::GetProperty(const char* prop) const
|
|
|
|
{
|
2006-12-07 17:45:32 +03:00
|
|
|
bool chain = false;
|
|
|
|
const char *retVal =
|
|
|
|
this->Properties.GetPropertyValue(prop, cmProperty::TEST, chain);
|
|
|
|
if (chain)
|
2005-07-31 19:51:42 +04:00
|
|
|
{
|
2006-12-07 17:45:32 +03:00
|
|
|
return this->Makefile->GetProperty(prop,cmProperty::TEST);
|
2005-07-31 19:51:42 +04:00
|
|
|
}
|
2006-12-07 18:22:19 +03:00
|
|
|
return retVal;
|
2005-07-31 19:51:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool cmTest::GetPropertyAsBool(const char* prop) const
|
|
|
|
{
|
2006-12-07 17:45:32 +03:00
|
|
|
return cmSystemTools::IsOn(this->GetProperty(prop));
|
2005-07-31 19:51:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmTest::SetProperty(const char* prop, const char* value)
|
|
|
|
{
|
|
|
|
if (!prop)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2006-12-07 17:45:32 +03:00
|
|
|
|
|
|
|
this->Properties.SetProperty(prop, value, cmProperty::TEST);
|
|
|
|
}
|
|
|
|
|
2008-01-18 02:13:55 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmTest::AppendProperty(const char* prop, const char* value)
|
|
|
|
{
|
|
|
|
if (!prop)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this->Properties.AppendProperty(prop, value, cmProperty::TEST);
|
|
|
|
}
|
|
|
|
|
2006-12-07 17:45:32 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmTest::SetMakefile(cmMakefile* mf)
|
|
|
|
{
|
|
|
|
// Set our makefile.
|
|
|
|
this->Makefile = mf;
|
|
|
|
this->Properties.SetCMakeInstance(mf->GetCMakeInstance());
|
2005-07-31 19:51:42 +04:00
|
|
|
}
|
|
|
|
|
2006-12-07 17:45:32 +03:00
|
|
|
// define properties
|
|
|
|
void cmTest::DefineProperties(cmake *cm)
|
|
|
|
{
|
|
|
|
// define properties
|
|
|
|
cm->DefineProperty
|
|
|
|
("FAIL_REGULAR_EXPRESSION", cmProperty::TEST,
|
2008-01-10 06:09:19 +03:00
|
|
|
"If the output matches this regular expression the test will fail.",
|
2006-12-07 17:45:32 +03: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\"");
|
|
|
|
|
|
|
|
cm->DefineProperty
|
|
|
|
("MEASUREMENT", cmProperty::TEST,
|
2008-01-10 06:09:19 +03:00
|
|
|
"Specify a DART measurement and value to be reported for a test.",
|
2006-12-07 17:45:32 +03:00
|
|
|
"If set to a name then that name will be reported to DART as a "
|
|
|
|
"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.");
|
|
|
|
|
2007-01-25 19:16:16 +03:00
|
|
|
cm->DefineProperty
|
|
|
|
("TIMEOUT", cmProperty::TEST,
|
|
|
|
"How many seconds to allow for this test.",
|
2008-01-10 06:09:19 +03:00
|
|
|
"This property if set will limit a test to not take more than "
|
2007-01-25 19:16:16 +03: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. "
|
|
|
|
"This setting takes precedence over DART_TESTING_TIMEOUT and "
|
2008-01-10 06:09:19 +03:00
|
|
|
"CTEST_TESTING_TIMEOUT.");
|
2007-01-25 19:16:16 +03:00
|
|
|
|
2006-12-07 17:45:32 +03: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.");
|
|
|
|
}
|