summaryrefslogtreecommitdiffstats
path: root/Source/CTest
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-01-15 20:23:07 (GMT)
committerBrad King <brad.king@kitware.com>2015-01-20 14:33:21 (GMT)
commit6dd980e0ef1254a6c3098488e6677f5eb4f40a86 (patch)
treef7d0568c3dbbc7ea23976f67ae016aab638fcb3e /Source/CTest
parent5dc33f89b5405f1fbcefb9783ea2050a3686d7de (diff)
downloadCMake-6dd980e0ef1254a6c3098488e6677f5eb4f40a86.zip
CMake-6dd980e0ef1254a6c3098488e6677f5eb4f40a86.tar.gz
CMake-6dd980e0ef1254a6c3098488e6677f5eb4f40a86.tar.bz2
ctest_submit: Make CDASH_UPLOAD mode arguments more strict
Disallow mixing of arguments from different command signatures. Extend the RunCMake.CTestSubmit test to cover such error cases.
Diffstat (limited to 'Source/CTest')
-rw-r--r--Source/CTest/cmCTestSubmitCommand.cxx89
-rw-r--r--Source/CTest/cmCTestSubmitCommand.h5
-rw-r--r--Source/CTest/cmCTestSubmitHandler.cxx14
3 files changed, 68 insertions, 40 deletions
diff --git a/Source/CTest/cmCTestSubmitCommand.cxx b/Source/CTest/cmCTestSubmitCommand.cxx
index dcd7982..cc3514f 100644
--- a/Source/CTest/cmCTestSubmitCommand.cxx
+++ b/Source/CTest/cmCTestSubmitCommand.cxx
@@ -145,7 +145,7 @@ cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler()
static_cast<cmCTestSubmitHandler*>(handler)->SetOption("InternalTest",
this->InternalTest ? "ON" : "OFF");
- if(this->CDashUploadFile.size())
+ if (this->CDashUpload)
{
static_cast<cmCTestSubmitHandler*>(handler)->
SetOption("CDashUploadFile", this->CDashUploadFile.c_str());
@@ -155,51 +155,65 @@ cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler()
return handler;
}
+//----------------------------------------------------------------------------
+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);
+}
//----------------------------------------------------------------------------
bool cmCTestSubmitCommand::CheckArgumentKeyword(std::string const& arg)
{
- // Look for arguments specific to this command.
- if(arg == "PARTS")
+ if (this->CDashUpload)
{
- this->ArgumentDoing = ArgumentDoingParts;
- this->PartsMentioned = true;
- return true;
- }
+ if(arg == "CDASH_UPLOAD")
+ {
+ this->ArgumentDoing = ArgumentDoingCDashUpload;
+ return true;
+ }
- if(arg == "FILES")
- {
- this->ArgumentDoing = ArgumentDoingFiles;
- this->FilesMentioned = true;
- return true;
+ if(arg == "CDASH_UPLOAD_TYPE")
+ {
+ this->ArgumentDoing = ArgumentDoingCDashUploadType;
+ return true;
+ }
}
-
- if(arg == "RETRY_COUNT")
+ else
{
- this->ArgumentDoing = ArgumentDoingRetryCount;
- return true;
- }
+ // Look for arguments specific to this command.
+ if(arg == "PARTS")
+ {
+ this->ArgumentDoing = ArgumentDoingParts;
+ this->PartsMentioned = true;
+ return true;
+ }
- if(arg == "RETRY_DELAY")
- {
- this->ArgumentDoing = ArgumentDoingRetryDelay;
- return true;
- }
+ if(arg == "FILES")
+ {
+ this->ArgumentDoing = ArgumentDoingFiles;
+ this->FilesMentioned = true;
+ return true;
+ }
- if(arg == "CDASH_UPLOAD")
- {
- this->ArgumentDoing = ArgumentDoingCDashUpload;
- return true;
- }
- if(arg == "CDASH_UPLOAD_TYPE")
- {
- this->ArgumentDoing = ArgumentDoingCDashUploadType;
- return true;
- }
- if(arg == "INTERNAL_TEST_CHECKSUM")
- {
- this->InternalTest = true;
- return true;
+ if(arg == "RETRY_COUNT")
+ {
+ this->ArgumentDoing = ArgumentDoingRetryCount;
+ return true;
+ }
+
+ if(arg == "RETRY_DELAY")
+ {
+ this->ArgumentDoing = ArgumentDoingRetryDelay;
+ return true;
+ }
+
+ if(arg == "INTERNAL_TEST_CHECKSUM")
+ {
+ this->InternalTest = true;
+ return true;
+ }
}
// Look for other arguments.
@@ -260,11 +274,14 @@ bool cmCTestSubmitCommand::CheckArgumentValue(std::string const& arg)
if(this->ArgumentDoing == ArgumentDoingCDashUpload)
{
+ this->ArgumentDoing = ArgumentDoingNone;
this->CDashUploadFile = arg;
return true;
}
+
if(this->ArgumentDoing == ArgumentDoingCDashUploadType)
{
+ this->ArgumentDoing = ArgumentDoingNone;
this->CDashUploadType = arg;
return true;
}
diff --git a/Source/CTest/cmCTestSubmitCommand.h b/Source/CTest/cmCTestSubmitCommand.h
index cb0ac61..19e8eaf 100644
--- a/Source/CTest/cmCTestSubmitCommand.h
+++ b/Source/CTest/cmCTestSubmitCommand.h
@@ -32,6 +32,7 @@ public:
this->InternalTest = false;
this->RetryCount = "";
this->RetryDelay = "";
+ this->CDashUpload = false;
}
/**
@@ -45,6 +46,9 @@ public:
return ni;
}
+ virtual bool InitialPass(std::vector<std::string> const& args,
+ cmExecutionStatus &status);
+
/**
* The name of the command as specified in CMakeList.txt.
*/
@@ -76,6 +80,7 @@ protected:
cmCTest::SetOfStrings Files;
std::string RetryCount;
std::string RetryDelay;
+ bool CDashUpload;
std::string CDashUploadFile;
std::string CDashUploadType;
};
diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx
index 0e19259..11e3343 100644
--- a/Source/CTest/cmCTestSubmitHandler.cxx
+++ b/Source/CTest/cmCTestSubmitHandler.cxx
@@ -1084,10 +1084,16 @@ void cmCTestSubmitHandler::ConstructCDashURL(std::string& dropMethod,
int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file,
std::string const& typeString)
{
- if(!cmSystemTools::FileExists(file))
+ if (file.empty())
{
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Upload file not found: " << file << "\n");
+ "Upload file not specified\n");
+ return -1;
+ }
+ if (!cmSystemTools::FileExists(file))
+ {
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Upload file not found: '" << file << "'\n");
return -1;
}
cmCTestCurl curl(this->CTest);
@@ -1118,6 +1124,7 @@ int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file,
static_cast<cmCTestScriptHandler*>(this->CTest->GetHandler("script"));
cmake* cm = ch->GetCMake();
const char* subproject = cm->GetProperty("SubProject", cmProperty::GLOBAL);
+ // TODO: Encode values for a URL instead of trusting caller.
std::ostringstream str;
str << "project="
<< this->CTest->GetCTestConfiguration("ProjectName") << "&";
@@ -1214,8 +1221,7 @@ int cmCTestSubmitHandler::ProcessHandler()
const char* cdashUploadType = this->GetOption("CDashUploadType");
if(cdashUploadFile && cdashUploadType)
{
- return this->HandleCDashUploadFile(std::string(cdashUploadFile),
- std::string(cdashUploadType));
+ return this->HandleCDashUploadFile(cdashUploadFile, cdashUploadType);
}
std::string iscdash = this->CTest->GetCTestConfiguration("IsCDash");
// cdash does not need to trigger so just return true