CTest: Add cmCTestOptionalLog macro
cmCTestOptionalLog takes a boolean argument that indicates whether or not the message should be suppressed. Note that error messages will still be printed, even if suppression is requested. This macro will allow us to provide more fine-grained control over what messages CTest prints to the console.
This commit is contained in:
parent
e2b9e7f7bc
commit
12db113944
|
@ -2741,10 +2741,11 @@ void cmCTest::DetermineNextDayStop()
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void cmCTest::SetCTestConfiguration(const char *name, const char* value)
|
void cmCTest::SetCTestConfiguration(const char *name, const char* value,
|
||||||
|
bool suppress)
|
||||||
{
|
{
|
||||||
cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "SetCTestConfiguration:"
|
cmCTestOptionalLog(this, HANDLER_VERBOSE_OUTPUT, "SetCTestConfiguration:"
|
||||||
<< name << ":" << (value ? value : "(null)") << "\n");
|
<< name << ":" << (value ? value : "(null)") << "\n", suppress);
|
||||||
|
|
||||||
if ( !name )
|
if ( !name )
|
||||||
{
|
{
|
||||||
|
@ -2858,7 +2859,7 @@ void cmCTest::SetConfigType(const char* ct)
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
bool cmCTest::SetCTestConfigurationFromCMakeVariable(cmMakefile* mf,
|
bool cmCTest::SetCTestConfigurationFromCMakeVariable(cmMakefile* mf,
|
||||||
const char* dconfig, const std::string& cmake_var)
|
const char* dconfig, const std::string& cmake_var, bool suppress)
|
||||||
{
|
{
|
||||||
const char* ctvar;
|
const char* ctvar;
|
||||||
ctvar = mf->GetDefinition(cmake_var);
|
ctvar = mf->GetDefinition(cmake_var);
|
||||||
|
@ -2866,10 +2867,10 @@ bool cmCTest::SetCTestConfigurationFromCMakeVariable(cmMakefile* mf,
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
cmCTestLog(this, HANDLER_VERBOSE_OUTPUT,
|
cmCTestOptionalLog(this, HANDLER_VERBOSE_OUTPUT,
|
||||||
"SetCTestConfigurationFromCMakeVariable:"
|
"SetCTestConfigurationFromCMakeVariable:" << dconfig << ":" <<
|
||||||
<< dconfig << ":" << cmake_var << std::endl);
|
cmake_var << std::endl, suppress);
|
||||||
this->SetCTestConfiguration(dconfig, ctvar);
|
this->SetCTestConfiguration(dconfig, ctvar, suppress);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3034,12 +3035,17 @@ void cmCTest::InitStreams()
|
||||||
this->StreamErr = &std::cerr;
|
this->StreamErr = &std::cerr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmCTest::Log(int logType, const char* file, int line, const char* msg)
|
void cmCTest::Log(int logType, const char* file, int line, const char* msg,
|
||||||
|
bool suppress)
|
||||||
{
|
{
|
||||||
if ( !msg || !*msg )
|
if ( !msg || !*msg )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if ( suppress && logType != cmCTest::ERROR_MESSAGE )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
if ( this->OutputLogFile )
|
if ( this->OutputLogFile )
|
||||||
{
|
{
|
||||||
bool display = true;
|
bool display = true;
|
||||||
|
|
|
@ -33,6 +33,14 @@ class cmCTestStartCommand;
|
||||||
cmCTestLog_msg.str().c_str());\
|
cmCTestLog_msg.str().c_str());\
|
||||||
} while ( 0 )
|
} while ( 0 )
|
||||||
|
|
||||||
|
#define cmCTestOptionalLog(ctSelf, logType, msg, suppress) \
|
||||||
|
do { \
|
||||||
|
std::ostringstream cmCTestLog_msg; \
|
||||||
|
cmCTestLog_msg << msg; \
|
||||||
|
(ctSelf)->Log(cmCTest::logType, __FILE__, __LINE__,\
|
||||||
|
cmCTestLog_msg.str().c_str(), suppress);\
|
||||||
|
} while ( 0 )
|
||||||
|
|
||||||
#ifdef cerr
|
#ifdef cerr
|
||||||
# undef cerr
|
# undef cerr
|
||||||
#endif
|
#endif
|
||||||
|
@ -173,7 +181,8 @@ public:
|
||||||
static int GetTestModelFromString(const char* str);
|
static int GetTestModelFromString(const char* str);
|
||||||
static std::string CleanString(const std::string& str);
|
static std::string CleanString(const std::string& str);
|
||||||
std::string GetCTestConfiguration(const std::string& name);
|
std::string GetCTestConfiguration(const std::string& name);
|
||||||
void SetCTestConfiguration(const char *name, const char* value);
|
void SetCTestConfiguration(const char *name, const char* value,
|
||||||
|
bool suppress=false);
|
||||||
void EmptyCTestConfiguration();
|
void EmptyCTestConfiguration();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -332,7 +341,7 @@ public:
|
||||||
* Set the CTest variable from CMake variable
|
* Set the CTest variable from CMake variable
|
||||||
*/
|
*/
|
||||||
bool SetCTestConfigurationFromCMakeVariable(cmMakefile* mf,
|
bool SetCTestConfigurationFromCMakeVariable(cmMakefile* mf,
|
||||||
const char* dconfig, const std::string& cmake_var);
|
const char* dconfig, const std::string& cmake_var, bool suppress=false);
|
||||||
|
|
||||||
//! Make string safe to be send as an URL
|
//! Make string safe to be send as an URL
|
||||||
static std::string MakeURLSafe(const std::string&);
|
static std::string MakeURLSafe(const std::string&);
|
||||||
|
@ -376,7 +385,8 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Add log to the output
|
//! Add log to the output
|
||||||
void Log(int logType, const char* file, int line, const char* msg);
|
void Log(int logType, const char* file, int line, const char* msg,
|
||||||
|
bool suppress=false);
|
||||||
|
|
||||||
//! Get the version of dart server
|
//! Get the version of dart server
|
||||||
int GetDartVersion() { return this->DartVersion; }
|
int GetDartVersion() { return this->DartVersion; }
|
||||||
|
|
Loading…
Reference in New Issue