2016-09-27 19:01:08 +00:00
|
|
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
2005-01-27 16:43:22 +00:00
|
|
|
#include "cmCTestGenericHandler.h"
|
2016-04-29 13:40:20 +00:00
|
|
|
|
2016-11-25 21:10:40 +00:00
|
|
|
#include <cmConfigure.h>
|
2016-08-24 20:01:40 +00:00
|
|
|
#include <sstream>
|
|
|
|
#include <utility>
|
2005-06-23 17:04:18 +00:00
|
|
|
|
2016-11-25 21:10:40 +00:00
|
|
|
#include "cmCTest.h"
|
|
|
|
#include "cmSystemTools.h"
|
|
|
|
|
2005-01-27 16:43:22 +00:00
|
|
|
cmCTestGenericHandler::cmCTestGenericHandler()
|
|
|
|
{
|
2011-07-26 07:26:18 +00:00
|
|
|
this->HandlerVerbose = cmSystemTools::OUTPUT_NONE;
|
2016-06-27 20:44:16 +00:00
|
|
|
this->CTest = CM_NULLPTR;
|
2006-03-10 20:03:09 +00:00
|
|
|
this->SubmitIndex = 0;
|
2009-01-12 14:11:29 +00:00
|
|
|
this->AppendXML = false;
|
2015-02-16 21:02:14 +00:00
|
|
|
this->Quiet = false;
|
2015-06-09 12:50:44 +00:00
|
|
|
this->TestLoad = 0;
|
2005-01-27 16:43:22 +00:00
|
|
|
}
|
|
|
|
|
2005-01-27 20:54:47 +00:00
|
|
|
cmCTestGenericHandler::~cmCTestGenericHandler()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-02-04 21:06:56 +00:00
|
|
|
void cmCTestGenericHandler::SetOption(const std::string& op, const char* value)
|
2005-02-17 20:22:29 +00:00
|
|
|
{
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!value) {
|
|
|
|
cmCTestGenericHandler::t_StringToString::iterator remit =
|
|
|
|
this->Options.find(op);
|
|
|
|
if (remit != this->Options.end()) {
|
2006-03-10 20:03:09 +00:00
|
|
|
this->Options.erase(remit);
|
2005-02-17 20:22:29 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
return;
|
|
|
|
}
|
2005-02-17 20:22:29 +00:00
|
|
|
|
2006-03-10 20:03:09 +00:00
|
|
|
this->Options[op] = value;
|
2005-02-17 20:22:29 +00:00
|
|
|
}
|
|
|
|
|
2014-02-04 21:06:56 +00:00
|
|
|
void cmCTestGenericHandler::SetPersistentOption(const std::string& op,
|
2006-05-10 17:50:44 +00:00
|
|
|
const char* value)
|
2006-04-28 15:59:31 +00:00
|
|
|
{
|
2006-04-30 07:16:37 +00:00
|
|
|
this->SetOption(op, value);
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!value) {
|
|
|
|
cmCTestGenericHandler::t_StringToString::iterator remit =
|
|
|
|
this->PersistentOptions.find(op);
|
|
|
|
if (remit != this->PersistentOptions.end()) {
|
2006-04-28 15:59:31 +00:00
|
|
|
this->PersistentOptions.erase(remit);
|
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
return;
|
|
|
|
}
|
2006-04-28 15:59:31 +00:00
|
|
|
|
|
|
|
this->PersistentOptions[op] = value;
|
|
|
|
}
|
|
|
|
|
2005-06-23 17:04:18 +00:00
|
|
|
void cmCTestGenericHandler::Initialize()
|
|
|
|
{
|
2009-01-15 18:24:54 +00:00
|
|
|
this->AppendXML = false;
|
2015-06-09 12:50:44 +00:00
|
|
|
this->TestLoad = 0;
|
2006-03-10 20:03:09 +00:00
|
|
|
this->Options.clear();
|
2006-04-28 15:59:31 +00:00
|
|
|
t_StringToString::iterator it;
|
2016-05-16 14:34:04 +00:00
|
|
|
for (it = this->PersistentOptions.begin();
|
|
|
|
it != this->PersistentOptions.end(); ++it) {
|
2016-05-26 20:52:22 +00:00
|
|
|
this->Options[it->first] = it->second;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2005-06-23 17:04:18 +00:00
|
|
|
}
|
|
|
|
|
2014-02-04 21:06:56 +00:00
|
|
|
const char* cmCTestGenericHandler::GetOption(const std::string& op)
|
2005-02-17 20:22:29 +00:00
|
|
|
{
|
2016-05-16 14:34:04 +00:00
|
|
|
cmCTestGenericHandler::t_StringToString::iterator remit =
|
|
|
|
this->Options.find(op);
|
|
|
|
if (remit == this->Options.end()) {
|
2016-06-27 20:44:16 +00:00
|
|
|
return CM_NULLPTR;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2005-02-17 20:22:29 +00:00
|
|
|
return remit->second.c_str();
|
|
|
|
}
|
2005-01-27 20:54:47 +00:00
|
|
|
|
2009-01-12 15:37:55 +00:00
|
|
|
bool cmCTestGenericHandler::StartResultingXML(cmCTest::Part part,
|
|
|
|
const char* name,
|
|
|
|
cmGeneratedFileStream& xofs)
|
2005-06-23 17:04:18 +00:00
|
|
|
{
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!name) {
|
2006-03-10 20:03:09 +00:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
2016-05-16 14:34:04 +00:00
|
|
|
"Cannot create resulting XML file without providing the name"
|
|
|
|
<< std::endl;);
|
2005-06-23 17:04:18 +00:00
|
|
|
return false;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-01-05 19:31:31 +00:00
|
|
|
std::ostringstream ostr;
|
2005-06-23 17:04:18 +00:00
|
|
|
ostr << name;
|
2016-05-16 14:34:04 +00:00
|
|
|
if (this->SubmitIndex > 0) {
|
2006-03-10 20:03:09 +00:00
|
|
|
ostr << "_" << this->SubmitIndex;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2012-08-13 17:42:58 +00:00
|
|
|
ostr << ".xml";
|
2016-05-16 14:34:04 +00:00
|
|
|
if (this->CTest->GetCurrentTag().empty()) {
|
2007-08-03 20:44:57 +00:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
2008-12-30 14:13:02 +00:00
|
|
|
"Current Tag empty, this may mean NightlyStartTime / "
|
|
|
|
"CTEST_NIGHTLY_START_TIME was not set correctly. Or "
|
|
|
|
"maybe you forgot to call ctest_start() before calling "
|
2016-05-16 14:34:04 +00:00
|
|
|
"ctest_configure()."
|
|
|
|
<< std::endl);
|
2007-08-03 20:44:57 +00:00
|
|
|
cmSystemTools::SetFatalErrorOccured();
|
|
|
|
return false;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
if (!this->CTest->OpenOutputFile(this->CTest->GetCurrentTag(), ostr.str(),
|
|
|
|
xofs, true)) {
|
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot create resulting XML file: "
|
|
|
|
<< ostr.str() << std::endl);
|
2005-06-23 17:04:18 +00:00
|
|
|
return false;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2009-01-12 15:37:55 +00:00
|
|
|
this->CTest->AddSubmitFile(part, ostr.str().c_str());
|
2005-06-23 17:04:18 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2006-03-09 16:17:10 +00:00
|
|
|
bool cmCTestGenericHandler::StartLogFile(const char* name,
|
2016-05-16 14:34:04 +00:00
|
|
|
cmGeneratedFileStream& xofs)
|
2005-06-23 17:04:18 +00:00
|
|
|
{
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!name) {
|
2006-03-10 20:03:09 +00:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
2016-05-16 14:34:04 +00:00
|
|
|
"Cannot create log file without providing the name"
|
|
|
|
<< std::endl;);
|
2005-06-23 17:04:18 +00:00
|
|
|
return false;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-01-05 19:31:31 +00:00
|
|
|
std::ostringstream ostr;
|
2005-06-23 17:04:18 +00:00
|
|
|
ostr << "Last" << name;
|
2016-05-16 14:34:04 +00:00
|
|
|
if (this->SubmitIndex > 0) {
|
2006-03-10 20:03:09 +00:00
|
|
|
ostr << "_" << this->SubmitIndex;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
if (!this->CTest->GetCurrentTag().empty()) {
|
2006-03-10 20:03:09 +00:00
|
|
|
ostr << "_" << this->CTest->GetCurrentTag();
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2005-06-23 17:04:18 +00:00
|
|
|
ostr << ".log";
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!this->CTest->OpenOutputFile("Temporary", ostr.str(), xofs)) {
|
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
|
|
|
"Cannot create log file: " << ostr.str() << std::endl);
|
2005-06-23 17:04:18 +00:00
|
|
|
return false;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2005-06-23 17:04:18 +00:00
|
|
|
return true;
|
|
|
|
}
|