1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmCTestGenericHandler.cxx,v $
6 Date: $Date: 2007/08/28 17:46:57 $
7 Version: $Revision: 1.16 $
9 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
18 #include "cmCTestGenericHandler.h"
19 #include "cmSystemTools.h"
23 //----------------------------------------------------------------------
24 cmCTestGenericHandler::cmCTestGenericHandler()
26 this->HandlerVerbose
= false;
28 this->SubmitIndex
= 0;
31 //----------------------------------------------------------------------
32 cmCTestGenericHandler::~cmCTestGenericHandler()
36 //----------------------------------------------------------------------
37 void cmCTestGenericHandler::SetOption(const char* op
, const char* value
)
45 cmCTestGenericHandler::t_StringToString::iterator remit
46 = this->Options
.find(op
);
47 if ( remit
!= this->Options
.end() )
49 this->Options
.erase(remit
);
54 this->Options
[op
] = value
;
57 //----------------------------------------------------------------------
58 void cmCTestGenericHandler::SetPersistentOption(const char* op
,
61 this->SetOption(op
, value
);
68 cmCTestGenericHandler::t_StringToString::iterator remit
69 = this->PersistentOptions
.find(op
);
70 if ( remit
!= this->PersistentOptions
.end() )
72 this->PersistentOptions
.erase(remit
);
77 this->PersistentOptions
[op
] = value
;
80 //----------------------------------------------------------------------
81 void cmCTestGenericHandler::Initialize()
83 this->Options
.clear();
84 t_StringToString::iterator it
;
85 for ( it
= this->PersistentOptions
.begin();
86 it
!= this->PersistentOptions
.end();
89 this->Options
[it
->first
.c_str()] = it
->second
.c_str();
93 //----------------------------------------------------------------------
94 const char* cmCTestGenericHandler::GetOption(const char* op
)
96 cmCTestGenericHandler::t_StringToString::iterator remit
97 = this->Options
.find(op
);
98 if ( remit
== this->Options
.end() )
102 return remit
->second
.c_str();
105 //----------------------------------------------------------------------
106 bool cmCTestGenericHandler::StartResultingXML(const char* name
,
107 cmGeneratedFileStream
& xofs
)
111 cmCTestLog(this->CTest
, ERROR_MESSAGE
,
112 "Cannot create resulting XML file without providing the name"
116 cmOStringStream ostr
;
118 if ( this->SubmitIndex
> 0 )
120 ostr
<< "_" << this->SubmitIndex
;
123 if(this->CTest
->GetCurrentTag().empty())
125 cmCTestLog(this->CTest
, ERROR_MESSAGE
,
126 "Current Tag empty, this may mean"
127 " NightlyStartTime was not set correctly." << std::endl
);
128 cmSystemTools::SetFatalErrorOccured();
131 if( !this->CTest
->OpenOutputFile(this->CTest
->GetCurrentTag(),
132 ostr
.str().c_str(), xofs
, true) )
134 cmCTestLog(this->CTest
, ERROR_MESSAGE
,
135 "Cannot create resulting XML file: " << ostr
.str().c_str()
139 this->CTest
->AddSubmitFile(ostr
.str().c_str());
143 //----------------------------------------------------------------------
144 bool cmCTestGenericHandler::StartLogFile(const char* name
,
145 cmGeneratedFileStream
& xofs
)
149 cmCTestLog(this->CTest
, ERROR_MESSAGE
,
150 "Cannot create log file without providing the name" << std::endl
;);
153 cmOStringStream ostr
;
154 ostr
<< "Last" << name
;
155 if ( this->SubmitIndex
> 0 )
157 ostr
<< "_" << this->SubmitIndex
;
159 if ( !this->CTest
->GetCurrentTag().empty() )
161 ostr
<< "_" << this->CTest
->GetCurrentTag();
164 if( !this->CTest
->OpenOutputFile("Temporary", ostr
.str().c_str(), xofs
) )
166 cmCTestLog(this->CTest
, ERROR_MESSAGE
, "Cannot create log file: "
167 << ostr
.str().c_str() << std::endl
);