Commit c7feef30 authored by Andy Cedilnik's avatar Andy Cedilnik

ENH: Promote submit into a full handler, add test and submit command and do some cleanups

parent 4675aed7
SET (CTEST_PROJECT_NAME "CMake")
SET (CTEST_NIGHTLY_START_TIME "21:00:00 EDT")
SET (CTEST_DROP_METHOD "http")
SET (CTEST_DROP_SITE "public.kitware.com")
SET (CTEST_DROP_LOCATION "/cgi-bin/HTTPUploadDartFile.cgi")
SET (CTEST_TRIGGER_SITE
"http://${DROP_SITE}/cgi-bin/Submit-CMake-TestingResults.cgi")
SET (CTEST_TRIGGER_SITE "http://${CTEST_DROP_SITE}/cgi-bin/Submit-CMake-TestingResults.cgi")
......@@ -163,7 +163,9 @@ SET(CMTEST_SRCS cmCTest.cxx
CTest/cmCTestScriptHandler.cxx
CTest/cmCTestSleepCommand.cxx
CTest/cmCTestStartCommand.cxx
CTest/cmCTestSubmit.cxx
CTest/cmCTestSubmitCommand.cxx
CTest/cmCTestSubmitHandler.cxx
CTest/cmCTestTestCommand.cxx
CTest/cmCTestTestHandler.cxx
CTest/cmCTestUpdateCommand.cxx
CTest/cmCTestUpdateHandler.cxx
......
......@@ -197,13 +197,13 @@ void cmCTestBuildHandler::PopulateCustomVectors(cmMakefile *mf)
int cmCTestBuildHandler::ProcessHandler()
{
std::cout << "Build project" << std::endl;
std::string makeCommand = m_CTest->GetDartConfiguration("MakeCommand");
const std::string &makeCommand = m_CTest->GetDartConfiguration("MakeCommand");
if ( makeCommand.size() == 0 )
{
std::cerr << "Cannot find MakeCommand key in the DartConfiguration.tcl" << std::endl;
return -1;
}
std::string buildDirectory = m_CTest->GetDartConfiguration("BuildDirectory");
const std::string &buildDirectory = m_CTest->GetDartConfiguration("BuildDirectory");
if ( buildDirectory.size() == 0 )
{
std::cerr << "Cannot find BuildDirectory key in the DartConfiguration.tcl" << std::endl;
......
......@@ -49,6 +49,8 @@
#include "cmCTestSleepCommand.h"
#include "cmCTestStartCommand.h"
#include "cmCTestUpdateCommand.h"
#include "cmCTestTestCommand.h"
#include "cmCTestSubmitCommand.h"
#define CTEST_INITIAL_CMAKE_OUTPUT_FILE_NAME "CTestInitialCMakeOutput.log"
......@@ -229,6 +231,8 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg)
this->AddCTestCommand(new cmCTestRunScriptCommand);
this->AddCTestCommand(new cmCTestSleepCommand);
this->AddCTestCommand(new cmCTestStartCommand);
this->AddCTestCommand(new cmCTestSubmitCommand);
this->AddCTestCommand(new cmCTestTestCommand);
this->AddCTestCommand(new cmCTestUpdateCommand);
// add the script arg if defined
......
/*=========================================================================
Program: CMake - Cross-Platform Makefile Generator
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "cmCTestSubmitCommand.h"
#include "cmCTest.h"
#include "cmCTestGenericHandler.h"
bool cmCTestSubmitCommand::InitialPass(
std::vector<std::string> const& args)
{
if (args.size() != 1)
{
this->SetError("called with incorrect number of arguments");
return false;
}
const char* res_var = args[0].c_str();
m_CTest->SetDartConfigurationFromCMakeVariable(m_Makefile, "DropMethod", "CTEST_DROP_METHOD");
m_CTest->SetDartConfigurationFromCMakeVariable(m_Makefile, "DropSite", "CTEST_DROP_SITE");
m_CTest->SetDartConfigurationFromCMakeVariable(m_Makefile, "DropLocation", "CTEST_DROP_LOCATION");
m_CTest->SetDartConfigurationFromCMakeVariable(m_Makefile, "DropSiteUser", "CTEST_DROP_SITE_USER");
m_CTest->SetDartConfigurationFromCMakeVariable(m_Makefile, "DropSitePassword", "CTEST_DROP_SITE_PASSWORD");
m_CTest->SetDartConfigurationFromCMakeVariable(m_Makefile, "TriggerSite", "CTEST_TRIGGER_SITE");
m_CTest->SetDartConfigurationFromCMakeVariable(m_Makefile, "ScpCommand", "CTEST_SCP_COMMAND");
cmCTestGenericHandler* handler = m_CTest->GetHandler("submit");
if ( !handler )
{
this->SetError("internal CTest error. Cannot instantiate submit handler");
return false;
}
int res = handler->ProcessHandler();
cmOStringStream str;
str << res;
m_Makefile->AddDefinition(res_var, str.str().c_str());
return true;
}
/*=========================================================================
Program: CMake - Cross-Platform Makefile Generator
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef cmCTestSubmitCommand_h
#define cmCTestSubmitCommand_h
#include "cmCTestCommand.h"
/** \class cmCTestSubmit
* \brief Run a ctest script
*
* cmCTestSubmitCommand defineds the command to submit the test results for the project.
*/
class cmCTestSubmitCommand : public cmCTestCommand
{
public:
cmCTestSubmitCommand() {}
/**
* This is a virtual constructor for the command.
*/
virtual cmCommand* Clone()
{
cmCTestSubmitCommand* ni = new cmCTestSubmitCommand;
ni->m_CTest = this->m_CTest;
ni->m_CTestScriptHandler = this->m_CTestScriptHandler;
return ni;
}
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string> const& args);
/**
* The name of the command as specified in CMakeList.txt.
*/
virtual const char* GetName() { return "CTEST_SUBMIT";}
/**
* Succinct documentation.
*/
virtual const char* GetTerseDocumentation()
{
return "Submits the repository.";
}
/**
* More documentation.
*/
virtual const char* GetFullDocumentation()
{
return
" CTEST_SUBMIT(res)\n"
"Submits the test results for the project.";
}
cmTypeMacro(cmCTestSubmitCommand, cmCTestCommand);
};
#endif
......@@ -14,32 +14,32 @@
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef cmCTestSubmit_h
#define cmCTestSubmit_h
#ifndef cmCTestSubmitHandler_h
#define cmCTestSubmitHandler_h
#include "cmStandardIncludes.h"
#include "cmCTestGenericHandler.h"
/** \class cmCTestSubmit
/** \class cmCTestSubmitHandler
* \brief Helper class for CTest
*
* Submit testing results
*
*/
class cmCTestSubmit
class cmCTestSubmitHandler : public cmCTestGenericHandler
{
public:
cmCTestSubmit();
~cmCTestSubmit() { m_LogFile = 0; }
cmCTestSubmitHandler();
~cmCTestSubmitHandler() { m_LogFile = 0; }
/**
* Set verbosity of send
/*
* The main entry point for this class
*/
void SetVerbose(bool i) { m_Verbose = i; }
void VerboseOn() { this->SetVerbose(1); }
void VerboseOff() { this->SetVerbose(0); }
int ProcessHandler();
void SetLogFile(std::ostream* ost) { m_LogFile = ost; }
private:
void SetLogFile(std::ostream* ost) { m_LogFile = ost; }
/**
* Submit file using various ways
*/
......@@ -66,13 +66,13 @@ public:
const cmStdString& remoteprefix,
const cmStdString& url);
private:
std::string GetSubmitResultsPrefix();
cmStdString m_HTTPProxy;
int m_HTTPProxyType;
cmStdString m_HTTPProxyAuth;
cmStdString m_FTPProxy;
int m_FTPProxyType;
bool m_Verbose;
std::ostream* m_LogFile;
};
......
/*=========================================================================
Program: CMake - Cross-Platform Makefile Generator
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "cmCTestTestCommand.h"
#include "cmCTest.h"
#include "cmCTestGenericHandler.h"
bool cmCTestTestCommand::InitialPass(
std::vector<std::string> const& args)
{
if (args.size() != 2)
{
this->SetError("called with incorrect number of arguments");
return false;
}
const char* build_dir = args[0].c_str();
const char* res_var = args[1].c_str();
m_CTest->SetDartConfiguration("BuildDirectory", build_dir);
cmCTestGenericHandler* handler = m_CTest->GetHandler("test");
if ( !handler )
{
this->SetError("internal CTest error. Cannot instantiate test handler");
return false;
}
std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory();
cmSystemTools::ChangeDirectory(build_dir);
int res = handler->ProcessHandler();
cmSystemTools::ChangeDirectory(current_dir.c_str());
cmOStringStream str;
str << res;
m_Makefile->AddDefinition(res_var, str.str().c_str());
return true;
}
/*=========================================================================
Program: CMake - Cross-Platform Makefile Generator
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef cmCTestTestCommand_h
#define cmCTestTestCommand_h
#include "cmCTestCommand.h"
/** \class cmCTestTest
* \brief Run a ctest script
*
* cmCTestTestCommand defineds the command to test the project.
*/
class cmCTestTestCommand : public cmCTestCommand
{
public:
cmCTestTestCommand() {}
/**
* This is a virtual constructor for the command.
*/
virtual cmCommand* Clone()
{
cmCTestTestCommand* ni = new cmCTestTestCommand;
ni->m_CTest = this->m_CTest;
ni->m_CTestScriptHandler = this->m_CTestScriptHandler;
return ni;
}
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string> const& args);
/**
* The name of the command as specified in CMakeList.txt.
*/
virtual const char* GetName() { return "CTEST_TEST";}
/**
* Succinct documentation.
*/
virtual const char* GetTerseDocumentation()
{
return "Tests the repository.";
}
/**
* More documentation.
*/
virtual const char* GetFullDocumentation()
{
return
" CTEST_TEST(build_dir res)\n"
"Tests the given build directory and stores results in Test.xml. The "
"second argument is a variable that will hold value.";
}
cmTypeMacro(cmCTestTestCommand, cmCTestCommand);
};
#endif
......@@ -33,8 +33,8 @@
#include "cmCTestScriptHandler.h"
#include "cmCTestTestHandler.h"
#include "cmCTestUpdateHandler.h"
#include "cmCTestSubmitHandler.h"
#include "cmCTestSubmit.h"
#include "cmVersion.h"
#include <cmsys/RegularExpression.hxx>
......@@ -250,6 +250,7 @@ cmCTest::cmCTest()
m_TestingHandlers["update"] = new cmCTestUpdateHandler;
m_TestingHandlers["configure"] = new cmCTestConfigureHandler;
m_TestingHandlers["memcheck"] = new cmCTestMemCheckHandler;
m_TestingHandlers["submit"] = new cmCTestSubmitHandler;
cmCTest::t_TestingHandlers::iterator it;
for ( it = m_TestingHandlers.begin(); it != m_TestingHandlers.end(); ++ it )
......@@ -575,163 +576,6 @@ bool cmCTest::AddIfExists(tm_VectorOfStrings& files, const char* file)
return true;
}
int cmCTest::SubmitResults()
{
cmGeneratedFileStream ofs;
this->OpenOutputFile("Temporary", "LastSubmit.log", ofs);
cmCTest::tm_VectorOfStrings files;
std::string prefix = this->GetSubmitResultsPrefix();
// TODO:
// Check if test is enabled
this->AddIfExists(files, "Update.xml");
this->AddIfExists(files, "Configure.xml");
this->AddIfExists(files, "Build.xml");
this->AddIfExists(files, "Test.xml");
if ( this->AddIfExists(files, "Coverage.xml") )
{
cmCTest::tm_VectorOfStrings gfiles;
std::string gpath = m_BinaryDir + "/Testing/" + m_CurrentTag;
std::string::size_type glen = gpath.size() + 1;
gpath = gpath + "/CoverageLog*";
//std::cout << "Globbing for: " << gpath.c_str() << std::endl;
if ( cmSystemTools::SimpleGlob(gpath, gfiles, 1) )
{
size_t cc;
for ( cc = 0; cc < gfiles.size(); cc ++ )
{
gfiles[cc] = gfiles[cc].substr(glen);
//std::cout << "Glob file: " << gfiles[cc].c_str() << std::endl;
files.push_back(gfiles[cc]);
}
}
else
{
std::cerr << "Problem globbing" << std::endl;
}
}
this->AddIfExists(files, "DynamicAnalysis.xml");
this->AddIfExists(files, "Purify.xml");
this->AddIfExists(files, "Notes.xml");
if ( ofs )
{
ofs << "Upload files:" << std::endl;
int cnt = 0;
cmCTest::tm_VectorOfStrings::iterator it;
for ( it = files.begin(); it != files.end(); ++ it )
{
ofs << cnt << "\t" << it->c_str() << std::endl;
cnt ++;
}
}
std::cout << "Submit files (using " << m_DartConfiguration["DropMethod"] << ")"
<< std::endl;
cmCTestSubmit submit;
submit.SetVerbose(m_ExtraVerbose);
submit.SetLogFile(&ofs);
if ( m_DartConfiguration["DropMethod"] == "" ||
m_DartConfiguration["DropMethod"] == "ftp" )
{
ofs << "Using drop method: FTP" << std::endl;
std::cout << " Using FTP submit method" << std::endl;
std::string url = "ftp://";
url += cmCTest::MakeURLSafe(m_DartConfiguration["DropSiteUser"]) + ":" +
cmCTest::MakeURLSafe(m_DartConfiguration["DropSitePassword"]) + "@" +
m_DartConfiguration["DropSite"] +
cmCTest::MakeURLSafe(m_DartConfiguration["DropLocation"]);
if ( !submit.SubmitUsingFTP(m_BinaryDir+"/Testing/"+m_CurrentTag,
files, prefix, url) )
{
std::cerr << " Problems when submitting via FTP" << std::endl;
ofs << " Problems when submitting via FTP" << std::endl;
return 0;
}
if ( !submit.TriggerUsingHTTP(files, prefix, m_DartConfiguration["TriggerSite"]) )
{
std::cerr << " Problems when triggering via HTTP" << std::endl;
ofs << " Problems when triggering via HTTP" << std::endl;
return 0;
}
std::cout << " Submission successful" << std::endl;
ofs << " Submission successful" << std::endl;
return 1;
}
else if ( m_DartConfiguration["DropMethod"] == "http" )
{
ofs << "Using drop method: HTTP" << std::endl;
std::cout << " Using HTTP submit method" << std::endl;
std::string url = "http://";
if ( m_DartConfiguration["DropSiteUser"].size() > 0 )
{
url += m_DartConfiguration["DropSiteUser"];
if ( m_DartConfiguration["DropSitePassword"].size() > 0 )
{
url += ":" + m_DartConfiguration["DropSitePassword"];
}
url += "@";
}
url += m_DartConfiguration["DropSite"] + m_DartConfiguration["DropLocation"];
if ( !submit.SubmitUsingHTTP(m_BinaryDir+"/Testing/"+m_CurrentTag, files, prefix, url) )
{
std::cerr << " Problems when submitting via HTTP" << std::endl;
ofs << " Problems when submitting via HTTP" << std::endl;
return 0;
}
if ( !submit.TriggerUsingHTTP(files, prefix, m_DartConfiguration["TriggerSite"]) )
{
std::cerr << " Problems when triggering via HTTP" << std::endl;
ofs << " Problems when triggering via HTTP" << std::endl;
return 0;
}
std::cout << " Submission successful" << std::endl;
ofs << " Submission successful" << std::endl;
return 1;
}
else if ( m_DartConfiguration["DropMethod"] == "xmlrpc" )
{
ofs << "Using drop method: XML-RPC" << std::endl;
std::cout << " Using XML-RPC submit method" << std::endl;
std::string url = m_DartConfiguration["DropSite"];
prefix = m_DartConfiguration["DropLocation"];
if ( !submit.SubmitUsingXMLRPC(m_BinaryDir+"/Testing/"+m_CurrentTag, files, prefix, url) )
{
std::cerr << " Problems when submitting via XML-RPC" << std::endl;
ofs << " Problems when submitting via XML-RPC" << std::endl;
return 0;
}
std::cout << " Submission successful" << std::endl;
ofs << " Submission successful" << std::endl;
return 1;
}
else if ( m_DartConfiguration["DropMethod"] == "scp" )
{
std::string url;
if ( m_DartConfiguration["DropSiteUser"].size() > 0 )
{
url += m_DartConfiguration["DropSiteUser"] + "@";
}
url += m_DartConfiguration["DropSite"] + ":" + m_DartConfiguration["DropLocation"];
if ( !submit.SubmitUsingSCP(m_DartConfiguration["ScpCommand"],
m_BinaryDir+"/Testing/"+m_CurrentTag, files, prefix, url) )
{
std::cerr << " Problems when submitting via SCP" << std::endl;
ofs << " Problems when submitting via SCP" << std::endl;
return 0;
}
std::cout << " Submission successful" << std::endl;
ofs << " Submission successful" << std::endl;
}
else
{
std::cout << " Unknown submission method: \"" << m_DartConfiguration["DropMethod"] << "\"" << std::endl;
return 0;
}
return 0;
}
bool cmCTest::CTestFileExists(const std::string& filename)
{
std::string testingDir = m_BinaryDir + "/Testing/" + m_CurrentTag + "/" +
......@@ -739,15 +583,6 @@ bool cmCTest::CTestFileExists(const std::string& filename)
return cmSystemTools::FileExists(testingDir.c_str());
}
std::string cmCTest::GetSubmitResultsPrefix()
{
std::string name = m_DartConfiguration["Site"] +
"___" + m_DartConfiguration["BuildName"] +
"___" + m_CurrentTag + "-" +
this->GetTestModelString() + "___XML___";
return name;
}
cmCTestGenericHandler* cmCTest::GetHandler(const char* handler)
{
cmCTest::t_TestingHandlers::iterator it = m_TestingHandlers.find(handler);
......@@ -872,7 +707,10 @@ int cmCTest::ProcessTests()
if ( m_Tests[SUBMIT_TEST] || m_Tests[ALL_TEST] )
{
this->UpdateCTestConfiguration();
this->SubmitResults();
if (this->GetHandler("submit")->ProcessHandler() < 0)
{
res |= cmCTest::SUBMIT_ERRORS;
}
}
return res;
}
......
......@@ -71,12 +71,6 @@ public:
*/
int TestDirectory(bool memcheck);
/**
* Do submit testing results
*/
int SubmitResults();
std::string GetSubmitResultsPrefix();
///! what is the configuraiton type, e.g. Debug, Release etc.
std::string GetConfigType();
......@@ -166,12 +160,13 @@ public:
// provide some more detailed info on the return code for ctest
enum {
UPDATE_ERRORS = 0x01,
UPDATE_ERRORS = 0x01,
CONFIGURE_ERRORS = 0x02,
BUILD_ERRORS = 0x04,
TEST_ERRORS = 0x08,
MEMORY_ERRORS = 0x10,
COVERAGE_ERRORS = 0x20
BUILD_ERRORS = 0x04,
TEST_ERRORS = 0x08,
MEMORY_ERRORS = 0x10,
COVERAGE_ERRORS = 0x20,
SUBMIT_ERRORS = 0x40
};
///! Are we producing XML
......@@ -198,6 +193,8 @@ public:
*/
bool SetDartConfigurationFromCMakeVariable(cmMakefile* mf, const char* dconfig, const char* cmake_var);
//! Make string safe to be send as an URL
static std::string MakeURLSafe(const std::string&);
private:
std::string m_ConfigType;
bool m_Verbose;
......@@ -210,8 +207,6 @@ private:
int GenerateNotesFile(const char* files);
static std::string MakeURLSafe(const std::string&);
// these are helper classes
typedef std::map<cmStdString,cmCTestGenericHandler*> t_TestingHandlers;
t_TestingHandlers m_TestingHandlers;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment