2016-09-27 22:01:08 +03:00
|
|
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
2005-05-03 16:17:39 +04:00
|
|
|
#include "cmCTestSubmitCommand.h"
|
|
|
|
|
|
|
|
#include "cmCTest.h"
|
|
|
|
#include "cmCTestGenericHandler.h"
|
2009-01-12 18:38:27 +03:00
|
|
|
#include "cmCTestSubmitHandler.h"
|
2016-08-24 23:01:40 +03:00
|
|
|
#include "cmMakefile.h"
|
|
|
|
#include "cmSystemTools.h"
|
|
|
|
#include "cmake.h"
|
|
|
|
|
|
|
|
#include <sstream>
|
|
|
|
|
|
|
|
class cmExecutionStatus;
|
2005-05-03 16:17:39 +04:00
|
|
|
|
2006-03-29 21:01:24 +04:00
|
|
|
cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler()
|
2005-05-03 16:17:39 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* ctestDropMethod =
|
|
|
|
this->Makefile->GetDefinition("CTEST_DROP_METHOD");
|
|
|
|
const char* ctestDropSite = this->Makefile->GetDefinition("CTEST_DROP_SITE");
|
|
|
|
const char* ctestDropLocation =
|
|
|
|
this->Makefile->GetDefinition("CTEST_DROP_LOCATION");
|
|
|
|
const char* ctestTriggerSite =
|
|
|
|
this->Makefile->GetDefinition("CTEST_TRIGGER_SITE");
|
|
|
|
bool ctestDropSiteCDash = this->Makefile->IsOn("CTEST_DROP_SITE_CDASH");
|
|
|
|
const char* ctestProjectName =
|
|
|
|
this->Makefile->GetDefinition("CTEST_PROJECT_NAME");
|
|
|
|
if (!ctestDropMethod) {
|
2005-05-05 18:18:41 +04:00
|
|
|
ctestDropMethod = "http";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-02-03 19:52:54 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!ctestDropSite) {
|
2009-05-15 23:39:43 +04:00
|
|
|
// error: CDash requires CTEST_DROP_SITE definition
|
|
|
|
// in CTestConfig.cmake
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!ctestDropLocation) {
|
2009-05-15 23:39:43 +04:00
|
|
|
// error: CDash requires CTEST_DROP_LOCATION definition
|
|
|
|
// in CTestConfig.cmake
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-02-17 00:02:14 +03:00
|
|
|
this->CTest->SetCTestConfiguration("ProjectName", ctestProjectName,
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Quiet);
|
2015-02-17 00:02:14 +03:00
|
|
|
this->CTest->SetCTestConfiguration("DropMethod", ctestDropMethod,
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Quiet);
|
2015-02-17 00:02:14 +03:00
|
|
|
this->CTest->SetCTestConfiguration("DropSite", ctestDropSite, this->Quiet);
|
|
|
|
this->CTest->SetCTestConfiguration("DropLocation", ctestDropLocation,
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Quiet);
|
2009-02-03 19:52:54 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
this->CTest->SetCTestConfiguration(
|
|
|
|
"IsCDash", ctestDropSiteCDash ? "TRUE" : "FALSE", this->Quiet);
|
2009-02-03 19:52:54 +03:00
|
|
|
|
|
|
|
// Only propagate TriggerSite for non-CDash projects:
|
|
|
|
//
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!ctestDropSiteCDash) {
|
|
|
|
this->CTest->SetCTestConfiguration("TriggerSite", ctestTriggerSite,
|
|
|
|
this->Quiet);
|
|
|
|
}
|
|
|
|
|
|
|
|
this->CTest->SetCTestConfigurationFromCMakeVariable(
|
|
|
|
this->Makefile, "CurlOptions", "CTEST_CURL_OPTIONS", this->Quiet);
|
|
|
|
this->CTest->SetCTestConfigurationFromCMakeVariable(
|
|
|
|
this->Makefile, "DropSiteUser", "CTEST_DROP_SITE_USER", this->Quiet);
|
|
|
|
this->CTest->SetCTestConfigurationFromCMakeVariable(
|
|
|
|
this->Makefile, "DropSitePassword", "CTEST_DROP_SITE_PASSWORD",
|
|
|
|
this->Quiet);
|
|
|
|
this->CTest->SetCTestConfigurationFromCMakeVariable(
|
|
|
|
this->Makefile, "ScpCommand", "CTEST_SCP_COMMAND", this->Quiet);
|
2005-05-05 18:18:41 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* notesFilesVariable =
|
|
|
|
this->Makefile->GetDefinition("CTEST_NOTES_FILES");
|
|
|
|
if (notesFilesVariable) {
|
2005-05-08 21:49:06 +04:00
|
|
|
std::vector<std::string> notesFiles;
|
2014-02-10 09:21:34 +04:00
|
|
|
cmCTest::VectorOfStrings newNotesFiles;
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSystemTools::ExpandListArgument(notesFilesVariable, notesFiles);
|
|
|
|
newNotesFiles.insert(newNotesFiles.end(), notesFiles.begin(),
|
|
|
|
notesFiles.end());
|
2006-03-10 23:03:09 +03:00
|
|
|
this->CTest->GenerateNotesFile(newNotesFiles);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-02-03 19:52:54 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* extraFilesVariable =
|
|
|
|
this->Makefile->GetDefinition("CTEST_EXTRA_SUBMIT_FILES");
|
|
|
|
if (extraFilesVariable) {
|
2005-07-18 20:53:48 +04:00
|
|
|
std::vector<std::string> extraFiles;
|
2014-02-10 09:21:34 +04:00
|
|
|
cmCTest::VectorOfStrings newExtraFiles;
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSystemTools::ExpandListArgument(extraFilesVariable, extraFiles);
|
|
|
|
newExtraFiles.insert(newExtraFiles.end(), extraFiles.begin(),
|
|
|
|
extraFiles.end());
|
|
|
|
if (!this->CTest->SubmitExtraFiles(newExtraFiles)) {
|
2005-07-18 20:53:48 +04:00
|
|
|
this->SetError("problem submitting extra files.");
|
2016-06-27 23:44:16 +03:00
|
|
|
return CM_NULLPTR;
|
2005-07-18 20:53:48 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-05-08 21:49:06 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCTestGenericHandler* handler =
|
|
|
|
this->CTest->GetInitializedHandler("submit");
|
|
|
|
if (!handler) {
|
2005-05-03 16:17:39 +04:00
|
|
|
this->SetError("internal CTest error. Cannot instantiate submit handler");
|
2016-06-27 23:44:16 +03:00
|
|
|
return CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-01-12 18:38:27 +03:00
|
|
|
|
2009-02-03 19:52:54 +03:00
|
|
|
// If no FILES or PARTS given, *all* PARTS are submitted by default.
|
|
|
|
//
|
|
|
|
// If FILES are given, but not PARTS, only the FILES are submitted
|
|
|
|
// and *no* PARTS are submitted.
|
|
|
|
// (This is why we select the empty "noParts" set in the
|
|
|
|
// FilesMentioned block below...)
|
|
|
|
//
|
|
|
|
// If PARTS are given, only the selected PARTS are submitted.
|
|
|
|
//
|
|
|
|
// If both PARTS and FILES are given, only the selected PARTS *and*
|
|
|
|
// all the given FILES are submitted.
|
|
|
|
|
|
|
|
// If given explicit FILES to submit, pass them to the handler.
|
|
|
|
//
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->FilesMentioned) {
|
2009-02-03 19:52:54 +03:00
|
|
|
// Intentionally select *no* PARTS. (Pass an empty set.) If PARTS
|
|
|
|
// were also explicitly mentioned, they will be selected below...
|
|
|
|
// But FILES with no PARTS mentioned should just submit the FILES
|
|
|
|
// without any of the default parts.
|
|
|
|
//
|
|
|
|
std::set<cmCTest::Part> noParts;
|
|
|
|
static_cast<cmCTestSubmitHandler*>(handler)->SelectParts(noParts);
|
|
|
|
|
|
|
|
static_cast<cmCTestSubmitHandler*>(handler)->SelectFiles(this->Files);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-02-03 19:52:54 +03:00
|
|
|
|
2009-01-12 18:38:27 +03:00
|
|
|
// If a PARTS option was given, select only the named parts for submission.
|
2009-02-03 19:52:54 +03:00
|
|
|
//
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->PartsMentioned) {
|
2009-01-12 18:38:27 +03:00
|
|
|
static_cast<cmCTestSubmitHandler*>(handler)->SelectParts(this->Parts);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-02-03 19:52:54 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
static_cast<cmCTestSubmitHandler*>(handler)->SetOption(
|
|
|
|
"RetryDelay", this->RetryDelay.c_str());
|
|
|
|
static_cast<cmCTestSubmitHandler*>(handler)->SetOption(
|
|
|
|
"RetryCount", this->RetryCount.c_str());
|
|
|
|
static_cast<cmCTestSubmitHandler*>(handler)->SetOption(
|
|
|
|
"InternalTest", this->InternalTest ? "ON" : "OFF");
|
2010-06-03 18:34:34 +04:00
|
|
|
|
2015-02-17 00:02:14 +03:00
|
|
|
handler->SetQuiet(this->Quiet);
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->CDashUpload) {
|
|
|
|
static_cast<cmCTestSubmitHandler*>(handler)->SetOption(
|
|
|
|
"CDashUploadFile", this->CDashUploadFile.c_str());
|
|
|
|
static_cast<cmCTestSubmitHandler*>(handler)->SetOption(
|
|
|
|
"CDashUploadType", this->CDashUploadType.c_str());
|
|
|
|
}
|
2006-03-29 21:01:24 +04:00
|
|
|
return handler;
|
2005-05-03 16:17:39 +04:00
|
|
|
}
|
|
|
|
|
2015-01-15 23:23:07 +03:00
|
|
|
bool cmCTestSubmitCommand::InitialPass(std::vector<std::string> const& args,
|
|
|
|
cmExecutionStatus& status)
|
|
|
|
{
|
|
|
|
this->CDashUpload = !args.empty() && args[0] == "CDASH_UPLOAD";
|
|
|
|
return this->cmCTestHandlerCommand::InitialPass(args, status);
|
|
|
|
}
|
2005-05-03 16:17:39 +04:00
|
|
|
|
2009-01-12 18:38:27 +03:00
|
|
|
bool cmCTestSubmitCommand::CheckArgumentKeyword(std::string const& arg)
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->CDashUpload) {
|
|
|
|
if (arg == "CDASH_UPLOAD") {
|
2015-01-15 23:23:07 +03:00
|
|
|
this->ArgumentDoing = ArgumentDoingCDashUpload;
|
|
|
|
return true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-02-03 19:52:54 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (arg == "CDASH_UPLOAD_TYPE") {
|
2015-01-15 23:23:07 +03:00
|
|
|
this->ArgumentDoing = ArgumentDoingCDashUploadType;
|
|
|
|
return true;
|
2009-01-12 18:38:27 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-01-15 23:23:07 +03:00
|
|
|
// Look for arguments specific to this command.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (arg == "PARTS") {
|
2015-01-15 23:23:07 +03:00
|
|
|
this->ArgumentDoing = ArgumentDoingParts;
|
|
|
|
this->PartsMentioned = true;
|
|
|
|
return true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-06-03 18:34:34 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (arg == "FILES") {
|
2015-01-15 23:23:07 +03:00
|
|
|
this->ArgumentDoing = ArgumentDoingFiles;
|
|
|
|
this->FilesMentioned = true;
|
|
|
|
return true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-06-03 18:34:34 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (arg == "RETRY_COUNT") {
|
2015-01-15 23:23:07 +03:00
|
|
|
this->ArgumentDoing = ArgumentDoingRetryCount;
|
|
|
|
return true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-01-15 23:23:07 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (arg == "RETRY_DELAY") {
|
2015-01-15 23:23:07 +03:00
|
|
|
this->ArgumentDoing = ArgumentDoingRetryDelay;
|
|
|
|
return true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-01-15 23:23:07 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (arg == "INTERNAL_TEST_CHECKSUM") {
|
2015-01-15 23:23:07 +03:00
|
|
|
this->InternalTest = true;
|
|
|
|
return true;
|
2010-06-10 20:25:49 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-06-10 20:25:49 +04:00
|
|
|
|
2009-01-12 18:38:27 +03:00
|
|
|
// Look for other arguments.
|
|
|
|
return this->Superclass::CheckArgumentKeyword(arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmCTestSubmitCommand::CheckArgumentValue(std::string const& arg)
|
|
|
|
{
|
|
|
|
// Handle states specific to this command.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->ArgumentDoing == ArgumentDoingParts) {
|
2009-01-12 18:38:27 +03:00
|
|
|
cmCTest::Part p = this->CTest->GetPartFromName(arg.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
if (p != cmCTest::PartCount) {
|
2009-01-12 18:38:27 +03:00
|
|
|
this->Parts.insert(p);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2009-01-12 18:38:27 +03:00
|
|
|
e << "Part name \"" << arg << "\" is invalid.";
|
|
|
|
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
|
|
|
|
this->ArgumentDoing = ArgumentDoingError;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
return true;
|
|
|
|
}
|
2009-01-12 18:38:27 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->ArgumentDoing == ArgumentDoingFiles) {
|
2016-05-26 23:21:15 +03:00
|
|
|
if (cmSystemTools::FileExists(arg.c_str())) {
|
|
|
|
this->Files.insert(arg);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2016-05-26 23:21:15 +03:00
|
|
|
e << "File \"" << arg << "\" does not exist. Cannot submit "
|
2016-05-16 17:34:04 +03:00
|
|
|
<< "a non-existent file.";
|
2009-02-03 19:52:54 +03:00
|
|
|
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
|
|
|
|
this->ArgumentDoing = ArgumentDoingError;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
return true;
|
|
|
|
}
|
2009-02-03 19:52:54 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->ArgumentDoing == ArgumentDoingRetryCount) {
|
2010-06-03 18:34:34 +04:00
|
|
|
this->RetryCount = arg;
|
2010-06-10 20:25:49 +04:00
|
|
|
return true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-06-03 18:34:34 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->ArgumentDoing == ArgumentDoingRetryDelay) {
|
2010-06-03 18:34:34 +04:00
|
|
|
this->RetryDelay = arg;
|
2010-06-10 20:25:49 +04:00
|
|
|
return true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-06-03 18:34:34 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->ArgumentDoing == ArgumentDoingCDashUpload) {
|
2015-01-15 23:23:07 +03:00
|
|
|
this->ArgumentDoing = ArgumentDoingNone;
|
2015-01-14 18:54:25 +03:00
|
|
|
this->CDashUploadFile = arg;
|
|
|
|
return true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-01-15 23:23:07 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->ArgumentDoing == ArgumentDoingCDashUploadType) {
|
2015-01-15 23:23:07 +03:00
|
|
|
this->ArgumentDoing = ArgumentDoingNone;
|
2015-01-14 18:54:25 +03:00
|
|
|
this->CDashUploadType = arg;
|
|
|
|
return true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-01-14 18:54:25 +03:00
|
|
|
|
2009-01-12 18:38:27 +03:00
|
|
|
// Look for other arguments.
|
|
|
|
return this->Superclass::CheckArgumentValue(arg);
|
|
|
|
}
|