1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmCTestGenericHandler.cxx,v $
6 Date: $Date: 2009-01-15 18:24:54 $
7 Version: $Revision: 1.21 $
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;
29 this->AppendXML
= false;
32 //----------------------------------------------------------------------
33 cmCTestGenericHandler::~cmCTestGenericHandler()
37 //----------------------------------------------------------------------
38 void cmCTestGenericHandler::SetOption(const char* op
, const char* value
)
46 cmCTestGenericHandler::t_StringToString::iterator remit
47 = this->Options
.find(op
);
48 if ( remit
!= this->Options
.end() )
50 this->Options
.erase(remit
);
55 this->Options
[op
] = value
;
58 //----------------------------------------------------------------------
59 void cmCTestGenericHandler::SetPersistentOption(const char* op
,
62 this->SetOption(op
, value
);
69 cmCTestGenericHandler::t_StringToString::iterator remit
70 = this->PersistentOptions
.find(op
);
71 if ( remit
!= this->PersistentOptions
.end() )
73 this->PersistentOptions
.erase(remit
);
78 this->PersistentOptions
[op
] = value
;
81 //----------------------------------------------------------------------
82 void cmCTestGenericHandler::Initialize()
84 this->AppendXML
= false;
85 this->Options
.clear();
86 t_StringToString::iterator it
;
87 for ( it
= this->PersistentOptions
.begin();
88 it
!= this->PersistentOptions
.end();
91 this->Options
[it
->first
.c_str()] = it
->second
.c_str();
95 //----------------------------------------------------------------------
96 const char* cmCTestGenericHandler::GetOption(const char* op
)
98 cmCTestGenericHandler::t_StringToString::iterator remit
99 = this->Options
.find(op
);
100 if ( remit
== this->Options
.end() )
104 return remit
->second
.c_str();
107 //----------------------------------------------------------------------
108 bool cmCTestGenericHandler::StartResultingXML(cmCTest::Part part
,
110 cmGeneratedFileStream
& xofs
)
114 cmCTestLog(this->CTest
, ERROR_MESSAGE
,
115 "Cannot create resulting XML file without providing the name"
119 cmOStringStream ostr
;
121 if ( this->SubmitIndex
> 0 )
123 ostr
<< "_" << this->SubmitIndex
;
126 if(this->CTest
->GetCurrentTag().empty())
128 cmCTestLog(this->CTest
, ERROR_MESSAGE
,
129 "Current Tag empty, this may mean NightlyStartTime / "
130 "CTEST_NIGHTLY_START_TIME was not set correctly. Or "
131 "maybe you forgot to call ctest_start() before calling "
132 "ctest_configure()." << std::endl
);
133 cmSystemTools::SetFatalErrorOccured();
136 if( !this->CTest
->OpenOutputFile(this->CTest
->GetCurrentTag(),
137 ostr
.str().c_str(), xofs
, true) )
139 cmCTestLog(this->CTest
, ERROR_MESSAGE
,
140 "Cannot create resulting XML file: " << ostr
.str().c_str()
144 this->CTest
->AddSubmitFile(part
, ostr
.str().c_str());
148 //----------------------------------------------------------------------
149 bool cmCTestGenericHandler::StartLogFile(const char* name
,
150 cmGeneratedFileStream
& xofs
)
154 cmCTestLog(this->CTest
, ERROR_MESSAGE
,
155 "Cannot create log file without providing the name" << std::endl
;);
158 cmOStringStream ostr
;
159 ostr
<< "Last" << name
;
160 if ( this->SubmitIndex
> 0 )
162 ostr
<< "_" << this->SubmitIndex
;
164 if ( !this->CTest
->GetCurrentTag().empty() )
166 ostr
<< "_" << this->CTest
->GetCurrentTag();
169 // if this is a parallel subprocess then add the id to the
170 // file so they don't clobber each other
171 if(this->CTest
->GetParallelSubprocess())
173 ostr
<< "." << this->CTest
->GetParallelSubprocessId();
175 if( !this->CTest
->OpenOutputFile("Temporary", ostr
.str().c_str(), xofs
) )
177 cmCTestLog(this->CTest
, ERROR_MESSAGE
, "Cannot create log file: "
178 << ostr
.str().c_str() << std::endl
);