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.
This commit is contained in:
parent
5dc33f89b5
commit
6dd980e0ef
|
@ -38,13 +38,15 @@ timed-out submission before attempting to re-submit.
|
||||||
The RETRY_COUNT option specifies how many times to retry a timed-out
|
The RETRY_COUNT option specifies how many times to retry a timed-out
|
||||||
submission.
|
submission.
|
||||||
|
|
||||||
|
Submit to CDash Upload API
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
::
|
::
|
||||||
|
|
||||||
ctest_submit([CDASH_UPLOAD file]
|
ctest_submit(CDASH_UPLOAD <file> [CDASH_UPLOAD_TYPE <type>])
|
||||||
[CDASH_UPLOAD_TYPE type_string])
|
|
||||||
|
|
||||||
This second signature is used to upload files to CDash via the CDash
|
This second signature is used to upload files to CDash via the CDash
|
||||||
file upload API. The api first sends a request to upload to CDash along
|
file upload API. The api first sends a request to upload to CDash along
|
||||||
with the md5 sum of the file. If CDash does not already have the file,
|
with a content hash of the file. If CDash does not already have the file,
|
||||||
then it is uploaded. Along with the file, a CDash type string is specified
|
then it is uploaded. Along with the file, a CDash type string is specified
|
||||||
to tell CDash which handler to use to process the data.
|
to tell CDash which handler to use to process the data.
|
||||||
|
|
|
@ -145,7 +145,7 @@ cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler()
|
||||||
static_cast<cmCTestSubmitHandler*>(handler)->SetOption("InternalTest",
|
static_cast<cmCTestSubmitHandler*>(handler)->SetOption("InternalTest",
|
||||||
this->InternalTest ? "ON" : "OFF");
|
this->InternalTest ? "ON" : "OFF");
|
||||||
|
|
||||||
if(this->CDashUploadFile.size())
|
if (this->CDashUpload)
|
||||||
{
|
{
|
||||||
static_cast<cmCTestSubmitHandler*>(handler)->
|
static_cast<cmCTestSubmitHandler*>(handler)->
|
||||||
SetOption("CDashUploadFile", this->CDashUploadFile.c_str());
|
SetOption("CDashUploadFile", this->CDashUploadFile.c_str());
|
||||||
|
@ -155,10 +155,33 @@ cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler()
|
||||||
return handler;
|
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)
|
bool cmCTestSubmitCommand::CheckArgumentKeyword(std::string const& arg)
|
||||||
{
|
{
|
||||||
|
if (this->CDashUpload)
|
||||||
|
{
|
||||||
|
if(arg == "CDASH_UPLOAD")
|
||||||
|
{
|
||||||
|
this->ArgumentDoing = ArgumentDoingCDashUpload;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(arg == "CDASH_UPLOAD_TYPE")
|
||||||
|
{
|
||||||
|
this->ArgumentDoing = ArgumentDoingCDashUploadType;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
// Look for arguments specific to this command.
|
// Look for arguments specific to this command.
|
||||||
if(arg == "PARTS")
|
if(arg == "PARTS")
|
||||||
{
|
{
|
||||||
|
@ -186,21 +209,12 @@ bool cmCTestSubmitCommand::CheckArgumentKeyword(std::string const& arg)
|
||||||
return 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")
|
if(arg == "INTERNAL_TEST_CHECKSUM")
|
||||||
{
|
{
|
||||||
this->InternalTest = true;
|
this->InternalTest = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Look for other arguments.
|
// Look for other arguments.
|
||||||
return this->Superclass::CheckArgumentKeyword(arg);
|
return this->Superclass::CheckArgumentKeyword(arg);
|
||||||
|
@ -260,11 +274,14 @@ bool cmCTestSubmitCommand::CheckArgumentValue(std::string const& arg)
|
||||||
|
|
||||||
if(this->ArgumentDoing == ArgumentDoingCDashUpload)
|
if(this->ArgumentDoing == ArgumentDoingCDashUpload)
|
||||||
{
|
{
|
||||||
|
this->ArgumentDoing = ArgumentDoingNone;
|
||||||
this->CDashUploadFile = arg;
|
this->CDashUploadFile = arg;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this->ArgumentDoing == ArgumentDoingCDashUploadType)
|
if(this->ArgumentDoing == ArgumentDoingCDashUploadType)
|
||||||
{
|
{
|
||||||
|
this->ArgumentDoing = ArgumentDoingNone;
|
||||||
this->CDashUploadType = arg;
|
this->CDashUploadType = arg;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ public:
|
||||||
this->InternalTest = false;
|
this->InternalTest = false;
|
||||||
this->RetryCount = "";
|
this->RetryCount = "";
|
||||||
this->RetryDelay = "";
|
this->RetryDelay = "";
|
||||||
|
this->CDashUpload = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,6 +46,9 @@ public:
|
||||||
return ni;
|
return ni;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual bool InitialPass(std::vector<std::string> const& args,
|
||||||
|
cmExecutionStatus &status);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the command as specified in CMakeList.txt.
|
* The name of the command as specified in CMakeList.txt.
|
||||||
*/
|
*/
|
||||||
|
@ -76,6 +80,7 @@ protected:
|
||||||
cmCTest::SetOfStrings Files;
|
cmCTest::SetOfStrings Files;
|
||||||
std::string RetryCount;
|
std::string RetryCount;
|
||||||
std::string RetryDelay;
|
std::string RetryDelay;
|
||||||
|
bool CDashUpload;
|
||||||
std::string CDashUploadFile;
|
std::string CDashUploadFile;
|
||||||
std::string CDashUploadType;
|
std::string CDashUploadType;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1084,10 +1084,16 @@ void cmCTestSubmitHandler::ConstructCDashURL(std::string& dropMethod,
|
||||||
int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file,
|
int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file,
|
||||||
std::string const& typeString)
|
std::string const& typeString)
|
||||||
{
|
{
|
||||||
if(!cmSystemTools::FileExists(file))
|
if (file.empty())
|
||||||
{
|
{
|
||||||
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
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;
|
return -1;
|
||||||
}
|
}
|
||||||
cmCTestCurl curl(this->CTest);
|
cmCTestCurl curl(this->CTest);
|
||||||
|
@ -1118,6 +1124,7 @@ int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file,
|
||||||
static_cast<cmCTestScriptHandler*>(this->CTest->GetHandler("script"));
|
static_cast<cmCTestScriptHandler*>(this->CTest->GetHandler("script"));
|
||||||
cmake* cm = ch->GetCMake();
|
cmake* cm = ch->GetCMake();
|
||||||
const char* subproject = cm->GetProperty("SubProject", cmProperty::GLOBAL);
|
const char* subproject = cm->GetProperty("SubProject", cmProperty::GLOBAL);
|
||||||
|
// TODO: Encode values for a URL instead of trusting caller.
|
||||||
std::ostringstream str;
|
std::ostringstream str;
|
||||||
str << "project="
|
str << "project="
|
||||||
<< this->CTest->GetCTestConfiguration("ProjectName") << "&";
|
<< this->CTest->GetCTestConfiguration("ProjectName") << "&";
|
||||||
|
@ -1214,8 +1221,7 @@ int cmCTestSubmitHandler::ProcessHandler()
|
||||||
const char* cdashUploadType = this->GetOption("CDashUploadType");
|
const char* cdashUploadType = this->GetOption("CDashUploadType");
|
||||||
if(cdashUploadFile && cdashUploadType)
|
if(cdashUploadFile && cdashUploadType)
|
||||||
{
|
{
|
||||||
return this->HandleCDashUploadFile(std::string(cdashUploadFile),
|
return this->HandleCDashUploadFile(cdashUploadFile, cdashUploadType);
|
||||||
std::string(cdashUploadType));
|
|
||||||
}
|
}
|
||||||
std::string iscdash = this->CTest->GetCTestConfiguration("IsCDash");
|
std::string iscdash = this->CTest->GetCTestConfiguration("IsCDash");
|
||||||
// cdash does not need to trigger so just return true
|
// cdash does not need to trigger so just return true
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
(-1|255)
|
|
@ -0,0 +1,2 @@
|
||||||
|
CMake Error at .*/Tests/RunCMake/CTestSubmit/CDashUploadFILES/test.cmake:[0-9]+ \(ctest_submit\):
|
||||||
|
ctest_submit called with unknown argument "FILES".
|
|
@ -0,0 +1 @@
|
||||||
|
(-1|255)
|
|
@ -0,0 +1 @@
|
||||||
|
Only http and https are supported for CDASH_UPLOAD
|
|
@ -0,0 +1 @@
|
||||||
|
(-1|255)
|
|
@ -0,0 +1 @@
|
||||||
|
Upload file not specified
|
|
@ -0,0 +1 @@
|
||||||
|
(-1|255)
|
|
@ -0,0 +1,2 @@
|
||||||
|
CMake Error at .*/Tests/RunCMake/CTestSubmit/CDashUploadPARTS/test.cmake:[0-9]+ \(ctest_submit\):
|
||||||
|
ctest_submit called with unknown argument "PARTS".
|
|
@ -0,0 +1 @@
|
||||||
|
(-1|255)
|
|
@ -0,0 +1,2 @@
|
||||||
|
CMake Error at .*/Tests/RunCMake/CTestSubmit/CDashUploadRETRY_COUNT/test.cmake:[0-9]+ \(ctest_submit\):
|
||||||
|
ctest_submit called with unknown argument "RETRY_COUNT".
|
|
@ -0,0 +1 @@
|
||||||
|
(-1|255)
|
|
@ -0,0 +1,2 @@
|
||||||
|
CMake Error at .*/Tests/RunCMake/CTestSubmit/CDashUploadRETRY_DELAY/test.cmake:[0-9]+ \(ctest_submit\):
|
||||||
|
ctest_submit called with unknown argument "RETRY_DELAY".
|
|
@ -0,0 +1 @@
|
||||||
|
(-1|255)
|
|
@ -0,0 +1,2 @@
|
||||||
|
CMake Error at .*/Tests/RunCMake/CTestSubmit/PARTSCDashUpload/test.cmake:[0-9]+ \(ctest_submit\):
|
||||||
|
Part name "CDASH_UPLOAD" is invalid.
|
|
@ -0,0 +1 @@
|
||||||
|
(-1|255)
|
|
@ -0,0 +1,2 @@
|
||||||
|
CMake Error at .*/Tests/RunCMake/CTestSubmit/PARTSCDashUploadType/test.cmake:[0-9]+ \(ctest_submit\):
|
||||||
|
Part name "CDASH_UPLOAD_TYPE" is invalid.
|
|
@ -32,6 +32,19 @@ run_ctest_submit(BadArg bad-arg)
|
||||||
run_ctest_submit(BadPARTS PARTS bad-part)
|
run_ctest_submit(BadPARTS PARTS bad-part)
|
||||||
run_ctest_submit(BadFILES FILES bad-file)
|
run_ctest_submit(BadFILES FILES bad-file)
|
||||||
run_ctest_submit(RepeatRETURN_VALUE RETURN_VALUE res RETURN_VALUE res)
|
run_ctest_submit(RepeatRETURN_VALUE RETURN_VALUE res RETURN_VALUE res)
|
||||||
|
run_ctest_submit(PARTSCDashUpload PARTS Configure CDASH_UPLOAD)
|
||||||
|
run_ctest_submit(PARTSCDashUploadType PARTS Configure CDASH_UPLOAD_TYPE)
|
||||||
|
run_ctest_submit(CDashUploadPARTS CDASH_UPLOAD bad-upload PARTS)
|
||||||
|
run_ctest_submit(CDashUploadFILES CDASH_UPLOAD bad-upload FILES)
|
||||||
|
run_ctest_submit(CDashUploadRETRY_COUNT CDASH_UPLOAD bad-upload RETRY_COUNT)
|
||||||
|
run_ctest_submit(CDashUploadRETRY_DELAY CDASH_UPLOAD bad-upload RETRY_DELAY)
|
||||||
|
run_ctest_submit(CDashUploadNone CDASH_UPLOAD)
|
||||||
|
|
||||||
|
function(run_ctest_CDashUploadFTP)
|
||||||
|
set(CASE_DROP_METHOD ftp)
|
||||||
|
run_ctest_submit(CDashUploadFTP CDASH_UPLOAD ${CMAKE_CURRENT_LIST_FILE})
|
||||||
|
endfunction()
|
||||||
|
run_ctest_CDashUploadFTP()
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# Test failed drops by various protocols
|
# Test failed drops by various protocols
|
||||||
|
|
Loading…
Reference in New Issue