ENH: Add FILES arg to the ctest_submit command. BUG: Propagate the IsCDash setting properly to the ctest configuration during a submit. Also, do not propagate TriggerSite for projects submitting to CDash. No triggers are necessary with CDash.

This commit is contained in:
David Cole 2009-02-03 11:52:54 -05:00
parent a1d7f82d68
commit 6f88b29121
4 changed files with 156 additions and 26 deletions

View File

@ -30,31 +30,66 @@ cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler()
= this->Makefile->GetDefinition("CTEST_DROP_LOCATION");
const char* ctestTriggerSite
= this->Makefile->GetDefinition("CTEST_TRIGGER_SITE");
bool ctestDropSiteCDash
= this->Makefile->IsOn("CTEST_DROP_SITE_CDASH");
if ( !ctestDropMethod )
{
ctestDropMethod = "http";
}
if ( !ctestDropSite )
if ( ctestDropSiteCDash )
{
ctestDropSite = "public.kitware.com";
// drop site is a CDash server...
//
if ( !ctestDropSite )
{
// error: CDash requires CTEST_DROP_SITE definition
// in CTestConfig.cmake
}
if ( !ctestDropLocation )
{
// error: CDash requires CTEST_DROP_LOCATION definition
// in CTestConfig.cmake
}
}
if ( !ctestDropLocation )
else
{
ctestDropLocation = "/cgi-bin/HTTPUploadDartFile.cgi";
}
if ( !ctestTriggerSite )
{
ctestTriggerSite
= "http://public.kitware.com/cgi-bin/Submit-Random-TestingResults.cgi";
cmCTestLog(this->CTest, HANDLER_OUTPUT, "* Use default trigger site: "
<< ctestTriggerSite << std::endl;);
// drop site is a *NOT* a CDash server...
//
// Keep all this code in case anybody out there is still
// using newer CMake with non-CDash servers
//
if ( !ctestDropSite )
{
ctestDropSite = "public.kitware.com";
}
if ( !ctestDropLocation )
{
ctestDropLocation = "/cgi-bin/HTTPUploadDartFile.cgi";
}
if ( !ctestTriggerSite )
{
ctestTriggerSite
= "http://public.kitware.com/cgi-bin/Submit-Random-TestingResults.cgi";
cmCTestLog(this->CTest, HANDLER_OUTPUT, "* Use default trigger site: "
<< ctestTriggerSite << std::endl;);
}
}
this->CTest->SetCTestConfiguration("DropMethod", ctestDropMethod);
this->CTest->SetCTestConfiguration("DropSite", ctestDropSite);
this->CTest->SetCTestConfiguration("DropMethod", ctestDropMethod);
this->CTest->SetCTestConfiguration("DropSite", ctestDropSite);
this->CTest->SetCTestConfiguration("DropLocation", ctestDropLocation);
this->CTest->SetCTestConfiguration("TriggerSite", ctestTriggerSite);
this->CTest->SetCTestConfiguration("IsCDash",
ctestDropSiteCDash ? "TRUE" : "FALSE");
// Only propagate TriggerSite for non-CDash projects:
//
if ( !ctestDropSiteCDash )
{
this->CTest->SetCTestConfiguration("TriggerSite", ctestTriggerSite);
}
this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
"DropSiteUser", "CTEST_DROP_SITE_USER");
@ -79,6 +114,7 @@ cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler()
}
this->CTest->GenerateNotesFile(newNotesFiles);
}
const char* extraFilesVariable
= this->Makefile->GetDefinition("CTEST_EXTRA_SUBMIT_FILES");
if (extraFilesVariable)
@ -108,16 +144,44 @@ cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler()
return 0;
}
// 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.
//
if(this->FilesMentioned)
{
// 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);
}
// If a PARTS option was given, select only the named parts for submission.
if(!this->Parts.empty())
//
if(this->PartsMentioned)
{
static_cast<cmCTestSubmitHandler*>(handler)->SelectParts(this->Parts);
}
return handler;
}
//----------------------------------------------------------------------------
bool cmCTestSubmitCommand::CheckArgumentKeyword(std::string const& arg)
{
@ -125,6 +189,14 @@ bool cmCTestSubmitCommand::CheckArgumentKeyword(std::string const& arg)
if(arg == "PARTS")
{
this->ArgumentDoing = ArgumentDoingParts;
this->PartsMentioned = true;
return true;
}
if(arg == "FILES")
{
this->ArgumentDoing = ArgumentDoingFiles;
this->FilesMentioned = true;
return true;
}
@ -132,6 +204,7 @@ bool cmCTestSubmitCommand::CheckArgumentKeyword(std::string const& arg)
return this->Superclass::CheckArgumentKeyword(arg);
}
//----------------------------------------------------------------------------
bool cmCTestSubmitCommand::CheckArgumentValue(std::string const& arg)
{
@ -153,6 +226,24 @@ bool cmCTestSubmitCommand::CheckArgumentValue(std::string const& arg)
return true;
}
if(this->ArgumentDoing == ArgumentDoingFiles)
{
cmStdString filename(arg);
if(cmSystemTools::FileExists(filename.c_str()))
{
this->Files.insert(filename);
}
else
{
cmOStringStream e;
e << "File \"" << filename << "\" does not exist. Cannot submit "
<< "a non-existent file.";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
this->ArgumentDoing = ArgumentDoingError;
}
return true;
}
// Look for other arguments.
return this->Superclass::CheckArgumentValue(arg);
}

View File

@ -30,7 +30,11 @@ class cmCTestSubmitCommand : public cmCTestHandlerCommand
{
public:
cmCTestSubmitCommand() {}
cmCTestSubmitCommand()
{
this->PartsMentioned = false;
this->FilesMentioned = false;
}
/**
* This is a virtual constructor for the command.
@ -62,10 +66,12 @@ public:
virtual const char* GetFullDocumentation()
{
return
" ctest_submit([RETURN_VALUE res] [PARTS ...])\n"
" ctest_submit([RETURN_VALUE res] [PARTS ...] [FILES ...])\n"
"Submits the test results for the project. "
"By default all available parts are submitted. "
"The PARTS option lists a subset of parts to be submitted.";
"The PARTS option lists a subset of parts to be submitted. "
"The FILES option explicitly lists specific files to be submitted. "
"Each individual file must exist at the time of the call.";
}
cmTypeMacro(cmCTestSubmitCommand, cmCTestHandlerCommand);
@ -75,12 +81,18 @@ protected:
virtual bool CheckArgumentKeyword(std::string const& arg);
virtual bool CheckArgumentValue(std::string const& arg);
enum
{
ArgumentDoingParts = Superclass::ArgumentDoingLast1,
ArgumentDoingFiles,
ArgumentDoingLast2
};
bool PartsMentioned;
std::set<cmCTest::Part> Parts;
bool FilesMentioned;
cmCTest::SetOfStrings Files;
};

View File

@ -82,6 +82,7 @@ void cmCTestSubmitHandler::Initialize()
this->FTPProxy = "";
this->FTPProxyType = 0;
this->LogFile = 0;
this->Files.clear();
}
//----------------------------------------------------------------------------
@ -852,9 +853,22 @@ int cmCTestSubmitHandler::ProcessHandler()
cmGeneratedFileStream ofs;
this->StartLogFile("Submit", ofs);
cmCTest::SetOfStrings files;
std::string prefix = this->GetSubmitResultsPrefix();
if (!this->Files.empty())
{
// Submit only the explicitly selected files:
//
files.insert(this->Files.begin(), this->Files.end());
}
// Add to the list of files to submit from any selected, existing parts:
//
// TODO:
// Check if test is enabled
this->CTest->AddIfExists(cmCTest::PartUpdate, "Update.xml");
this->CTest->AddIfExists(cmCTest::PartConfigure, "Configure.xml");
this->CTest->AddIfExists(cmCTest::PartBuild, "Build.xml");
@ -889,7 +903,6 @@ int cmCTestSubmitHandler::ProcessHandler()
this->CTest->AddIfExists(cmCTest::PartNotes, "Notes.xml");
// Query parts for files to submit.
cmCTest::SetOfStrings files;
for(cmCTest::Part p = cmCTest::PartStart;
p != cmCTest::PartCount; p = cmCTest::Part(p+1))
{
@ -919,6 +932,7 @@ int cmCTestSubmitHandler::ProcessHandler()
cnt ++;
}
}
cmCTestLog(this->CTest, HANDLER_OUTPUT, "Submit files (using "
<< this->CTest->GetCTestConfiguration("DropMethod") << ")"
<< std::endl);
@ -929,8 +943,10 @@ int cmCTestSubmitHandler::ProcessHandler()
<< specificTrack << std::endl);
}
this->SetLogFile(&ofs);
if ( this->CTest->GetCTestConfiguration("DropMethod") == "" ||
this->CTest->GetCTestConfiguration("DropMethod") == "ftp" )
cmStdString dropMethod(this->CTest->GetCTestConfiguration("DropMethod"));
if ( dropMethod == "" || dropMethod == "ftp" )
{
ofs << "Using drop method: FTP" << std::endl;
cmCTestLog(this->CTest, HANDLER_OUTPUT, " Using FTP submit method"
@ -990,7 +1006,7 @@ int cmCTestSubmitHandler::ProcessHandler()
return 0;
}
}
else if ( this->CTest->GetCTestConfiguration("DropMethod") == "http" )
else if ( dropMethod == "http" )
{
ofs << "Using drop method: HTTP" << std::endl;
cmCTestLog(this->CTest, HANDLER_OUTPUT, " Using HTTP submit method"
@ -1045,7 +1061,7 @@ int cmCTestSubmitHandler::ProcessHandler()
ofs << " Submission successful" << std::endl;
return 0;
}
else if ( this->CTest->GetCTestConfiguration("DropMethod") == "xmlrpc" )
else if ( dropMethod == "xmlrpc" )
{
ofs << "Using drop method: XML-RPC" << std::endl;
cmCTestLog(this->CTest, HANDLER_OUTPUT, " Using XML-RPC submit method"
@ -1065,7 +1081,7 @@ int cmCTestSubmitHandler::ProcessHandler()
ofs << " Submission successful" << std::endl;
return 0;
}
else if ( this->CTest->GetCTestConfiguration("DropMethod") == "scp" )
else if ( dropMethod == "scp" )
{
std::string url;
std::string oldWorkingDirectory;
@ -1100,7 +1116,7 @@ int cmCTestSubmitHandler::ProcessHandler()
}
cmCTestLog(this->CTest, ERROR_MESSAGE, " Unknown submission method: \""
<< this->CTest->GetCTestConfiguration("DropMethod") << "\"" << std::endl);
<< dropMethod << "\"" << std::endl);
return -1;
}
@ -1125,3 +1141,9 @@ void cmCTestSubmitHandler::SelectParts(std::set<cmCTest::Part> const& parts)
(std::set<cmCTest::Part>::const_iterator(parts.find(p)) != parts.end());
}
}
//----------------------------------------------------------------------------
void cmCTestSubmitHandler::SelectFiles(cmCTest::SetOfStrings const& files)
{
this->Files.insert(files.begin(), files.end());
}

View File

@ -42,6 +42,10 @@ public:
/** Specify a set of parts (by name) to submit. */
void SelectParts(std::set<cmCTest::Part> const& parts);
/** Specify a set of files to submit. */
void SelectFiles(cmCTest::SetOfStrings const& files);
private:
void SetLogFile(std::ostream* ost) { this->LogFile = ost; }
@ -81,6 +85,7 @@ private:
std::ostream* LogFile;
bool SubmitPart[cmCTest::PartCount];
bool CDash;
cmCTest::SetOfStrings Files;
};
#endif