CMake/Source/CTest/cmCTestGenericHandler.cxx

139 lines
3.9 KiB
C++
Raw Normal View History

Simplify CMake per-source license notices Per-source copyright/license notice headers that spell out copyright holder names and years are hard to maintain and often out-of-date or plain wrong. Precise contributor information is already maintained automatically by the version control tool. Ultimately it is the receiver of a file who is responsible for determining its licensing status, and per-source notices are merely a convenience. Therefore it is simpler and more accurate for each source to have a generic notice of the license name and references to more detailed information on copyright holders and full license terms. Our `Copyright.txt` file now contains a list of Contributors whose names appeared source-level copyright notices. It also references version control history for more precise information. Therefore we no longer need to spell out the list of Contributors in each source file notice. Replace CMake per-source copyright/license notice headers with a short description of the license and links to `Copyright.txt` and online information available from "https://cmake.org/licensing". The online URL also handles cases of modules being copied out of our source into other projects, so we can drop our notices about replacing links with full license text. Run the `Utilities/Scripts/filter-notices.bash` script to perform the majority of the replacements mechanically. Manually fix up shebang lines and trailing newlines in a few files. Manually update the notices in a few files that the script does not handle.
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-11-25 21:10:40 +00:00
#include <cmConfigure.h>
#include <sstream>
#include <utility>
2016-11-25 21:10:40 +00:00
#include "cmCTest.h"
#include "cmSystemTools.h"
2005-01-27 16:43:22 +00:00
cmCTestGenericHandler::cmCTestGenericHandler()
{
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;
this->AppendXML = false;
this->Quiet = false;
this->TestLoad = 0;
2005-01-27 16:43:22 +00:00
}
2005-01-27 20:54:47 +00:00
cmCTestGenericHandler::~cmCTestGenericHandler()
{
}
void cmCTestGenericHandler::SetOption(const std::string& op, const char* value)
{
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);
}
return;
}
2006-03-10 20:03:09 +00:00
this->Options[op] = value;
}
void cmCTestGenericHandler::SetPersistentOption(const std::string& op,
2006-05-10 17:50:44 +00:00
const char* value)
{
2006-04-30 07:16:37 +00:00
this->SetOption(op, value);
if (!value) {
cmCTestGenericHandler::t_StringToString::iterator remit =
this->PersistentOptions.find(op);
if (remit != this->PersistentOptions.end()) {
this->PersistentOptions.erase(remit);
}
return;
}
this->PersistentOptions[op] = value;
}
void cmCTestGenericHandler::Initialize()
{
this->AppendXML = false;
this->TestLoad = 0;
2006-03-10 20:03:09 +00:00
this->Options.clear();
t_StringToString::iterator it;
for (it = this->PersistentOptions.begin();
it != this->PersistentOptions.end(); ++it) {
this->Options[it->first] = it->second;
}
}
const char* cmCTestGenericHandler::GetOption(const std::string& op)
{
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;
}
return remit->second.c_str();
}
2005-01-27 20:54:47 +00:00
bool cmCTestGenericHandler::StartResultingXML(cmCTest::Part part,
const char* name,
cmGeneratedFileStream& xofs)
{
if (!name) {
2006-03-10 20:03:09 +00:00
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Cannot create resulting XML file without providing the name"
<< std::endl;);
return false;
}
std::ostringstream ostr;
ostr << name;
if (this->SubmitIndex > 0) {
2006-03-10 20:03:09 +00:00
ostr << "_" << this->SubmitIndex;
}
ostr << ".xml";
if (this->CTest->GetCurrentTag().empty()) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
"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 "
"ctest_configure()."
<< std::endl);
cmSystemTools::SetFatalErrorOccured();
return false;
}
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);
return false;
}
this->CTest->AddSubmitFile(part, ostr.str().c_str());
return true;
}
2006-03-09 16:17:10 +00:00
bool cmCTestGenericHandler::StartLogFile(const char* name,
cmGeneratedFileStream& xofs)
{
if (!name) {
2006-03-10 20:03:09 +00:00
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Cannot create log file without providing the name"
<< std::endl;);
return false;
}
std::ostringstream ostr;
ostr << "Last" << name;
if (this->SubmitIndex > 0) {
2006-03-10 20:03:09 +00:00
ostr << "_" << this->SubmitIndex;
}
if (!this->CTest->GetCurrentTag().empty()) {
2006-03-10 20:03:09 +00:00
ostr << "_" << this->CTest->GetCurrentTag();
}
ostr << ".log";
if (!this->CTest->OpenOutputFile("Temporary", ostr.str(), xofs)) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Cannot create log file: " << ostr.str() << std::endl);
return false;
}
return true;
}