Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / CTest / cmCTestSubmitCommand.cxx
blob962b069dfe68701e51036d80c27f215dca1c8446
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmCTestSubmitCommand.cxx,v $
5 Language: C++
6 Date: $Date: 2009-02-03 16:52:54 $
7 Version: $Revision: 1.15 $
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 =========================================================================*/
17 #include "cmCTestSubmitCommand.h"
19 #include "cmCTest.h"
20 #include "cmCTestGenericHandler.h"
21 #include "cmCTestSubmitHandler.h"
23 cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler()
25 const char* ctestDropMethod
26 = this->Makefile->GetDefinition("CTEST_DROP_METHOD");
27 const char* ctestDropSite
28 = this->Makefile->GetDefinition("CTEST_DROP_SITE");
29 const char* ctestDropLocation
30 = this->Makefile->GetDefinition("CTEST_DROP_LOCATION");
31 const char* ctestTriggerSite
32 = this->Makefile->GetDefinition("CTEST_TRIGGER_SITE");
33 bool ctestDropSiteCDash
34 = this->Makefile->IsOn("CTEST_DROP_SITE_CDASH");
36 if ( !ctestDropMethod )
38 ctestDropMethod = "http";
41 if ( ctestDropSiteCDash )
43 // drop site is a CDash server...
45 if ( !ctestDropSite )
47 // error: CDash requires CTEST_DROP_SITE definition
48 // in CTestConfig.cmake
50 if ( !ctestDropLocation )
52 // error: CDash requires CTEST_DROP_LOCATION definition
53 // in CTestConfig.cmake
56 else
58 // drop site is a *NOT* a CDash server...
60 // Keep all this code in case anybody out there is still
61 // using newer CMake with non-CDash servers
63 if ( !ctestDropSite )
65 ctestDropSite = "public.kitware.com";
67 if ( !ctestDropLocation )
69 ctestDropLocation = "/cgi-bin/HTTPUploadDartFile.cgi";
71 if ( !ctestTriggerSite )
73 ctestTriggerSite
74 = "http://public.kitware.com/cgi-bin/Submit-Random-TestingResults.cgi";
75 cmCTestLog(this->CTest, HANDLER_OUTPUT, "* Use default trigger site: "
76 << ctestTriggerSite << std::endl;);
80 this->CTest->SetCTestConfiguration("DropMethod", ctestDropMethod);
81 this->CTest->SetCTestConfiguration("DropSite", ctestDropSite);
82 this->CTest->SetCTestConfiguration("DropLocation", ctestDropLocation);
84 this->CTest->SetCTestConfiguration("IsCDash",
85 ctestDropSiteCDash ? "TRUE" : "FALSE");
87 // Only propagate TriggerSite for non-CDash projects:
89 if ( !ctestDropSiteCDash )
91 this->CTest->SetCTestConfiguration("TriggerSite", ctestTriggerSite);
94 this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
95 "DropSiteUser", "CTEST_DROP_SITE_USER");
96 this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
97 "DropSitePassword", "CTEST_DROP_SITE_PASSWORD");
98 this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
99 "ScpCommand", "CTEST_SCP_COMMAND");
101 const char* notesFilesVariable
102 = this->Makefile->GetDefinition("CTEST_NOTES_FILES");
103 if (notesFilesVariable)
105 std::vector<std::string> notesFiles;
106 std::vector<cmStdString> newNotesFiles;
107 cmSystemTools::ExpandListArgument(notesFilesVariable,notesFiles);
108 std::vector<std::string>::iterator it;
109 for ( it = notesFiles.begin();
110 it != notesFiles.end();
111 ++ it )
113 newNotesFiles.push_back(*it);
115 this->CTest->GenerateNotesFile(newNotesFiles);
118 const char* extraFilesVariable
119 = this->Makefile->GetDefinition("CTEST_EXTRA_SUBMIT_FILES");
120 if (extraFilesVariable)
122 std::vector<std::string> extraFiles;
123 std::vector<cmStdString> newExtraFiles;
124 cmSystemTools::ExpandListArgument(extraFilesVariable,extraFiles);
125 std::vector<std::string>::iterator it;
126 for ( it = extraFiles.begin();
127 it != extraFiles.end();
128 ++ it )
130 newExtraFiles.push_back(*it);
132 if ( !this->CTest->SubmitExtraFiles(newExtraFiles))
134 this->SetError("problem submitting extra files.");
135 return 0;
139 cmCTestGenericHandler* handler
140 = this->CTest->GetInitializedHandler("submit");
141 if ( !handler )
143 this->SetError("internal CTest error. Cannot instantiate submit handler");
144 return 0;
147 // If no FILES or PARTS given, *all* PARTS are submitted by default.
149 // If FILES are given, but not PARTS, only the FILES are submitted
150 // and *no* PARTS are submitted.
151 // (This is why we select the empty "noParts" set in the
152 // FilesMentioned block below...)
154 // If PARTS are given, only the selected PARTS are submitted.
156 // If both PARTS and FILES are given, only the selected PARTS *and*
157 // all the given FILES are submitted.
159 // If given explicit FILES to submit, pass them to the handler.
161 if(this->FilesMentioned)
163 // Intentionally select *no* PARTS. (Pass an empty set.) If PARTS
164 // were also explicitly mentioned, they will be selected below...
165 // But FILES with no PARTS mentioned should just submit the FILES
166 // without any of the default parts.
168 std::set<cmCTest::Part> noParts;
169 static_cast<cmCTestSubmitHandler*>(handler)->SelectParts(noParts);
171 static_cast<cmCTestSubmitHandler*>(handler)->SelectFiles(this->Files);
174 // If a PARTS option was given, select only the named parts for submission.
176 if(this->PartsMentioned)
178 static_cast<cmCTestSubmitHandler*>(handler)->SelectParts(this->Parts);
181 return handler;
185 //----------------------------------------------------------------------------
186 bool cmCTestSubmitCommand::CheckArgumentKeyword(std::string const& arg)
188 // Look for arguments specific to this command.
189 if(arg == "PARTS")
191 this->ArgumentDoing = ArgumentDoingParts;
192 this->PartsMentioned = true;
193 return true;
196 if(arg == "FILES")
198 this->ArgumentDoing = ArgumentDoingFiles;
199 this->FilesMentioned = true;
200 return true;
203 // Look for other arguments.
204 return this->Superclass::CheckArgumentKeyword(arg);
208 //----------------------------------------------------------------------------
209 bool cmCTestSubmitCommand::CheckArgumentValue(std::string const& arg)
211 // Handle states specific to this command.
212 if(this->ArgumentDoing == ArgumentDoingParts)
214 cmCTest::Part p = this->CTest->GetPartFromName(arg.c_str());
215 if(p != cmCTest::PartCount)
217 this->Parts.insert(p);
219 else
221 cmOStringStream e;
222 e << "Part name \"" << arg << "\" is invalid.";
223 this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
224 this->ArgumentDoing = ArgumentDoingError;
226 return true;
229 if(this->ArgumentDoing == ArgumentDoingFiles)
231 cmStdString filename(arg);
232 if(cmSystemTools::FileExists(filename.c_str()))
234 this->Files.insert(filename);
236 else
238 cmOStringStream e;
239 e << "File \"" << filename << "\" does not exist. Cannot submit "
240 << "a non-existent file.";
241 this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
242 this->ArgumentDoing = ArgumentDoingError;
244 return true;
247 // Look for other arguments.
248 return this->Superclass::CheckArgumentValue(arg);