ENH: Add support for CTestCustom.ctest, which modifies some behavior of ctest
This commit is contained in:
parent
222e9a2876
commit
2db971afb4
|
@ -21,6 +21,7 @@
|
||||||
#include "cmGlobalGenerator.h"
|
#include "cmGlobalGenerator.h"
|
||||||
#include <cmsys/Directory.hxx>
|
#include <cmsys/Directory.hxx>
|
||||||
#include "cmListFileCache.h"
|
#include "cmListFileCache.h"
|
||||||
|
#include "cmGlob.h"
|
||||||
|
|
||||||
#include "cmCTestSubmit.h"
|
#include "cmCTestSubmit.h"
|
||||||
#include "curl/curl.h"
|
#include "curl/curl.h"
|
||||||
|
@ -324,10 +325,14 @@ cmCTest::cmCTest()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmCTest::Initialize()
|
int cmCTest::Initialize()
|
||||||
{
|
{
|
||||||
m_ToplevelPath = cmSystemTools::GetCurrentWorkingDirectory();
|
m_ToplevelPath = cmSystemTools::GetCurrentWorkingDirectory();
|
||||||
cmSystemTools::ConvertToUnixSlashes(m_ToplevelPath);
|
cmSystemTools::ConvertToUnixSlashes(m_ToplevelPath);
|
||||||
|
if ( !this->ReadCustomConfigurationFileTree(m_ToplevelPath.c_str()) )
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
this->UpdateCTestConfiguration();
|
this->UpdateCTestConfiguration();
|
||||||
if ( m_DartMode )
|
if ( m_DartMode )
|
||||||
{
|
{
|
||||||
|
@ -338,7 +343,7 @@ void cmCTest::Initialize()
|
||||||
{
|
{
|
||||||
std::cerr << "File " << testingDir << " is in the place of the testing directory"
|
std::cerr << "File " << testingDir << " is in the place of the testing directory"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -347,7 +352,7 @@ void cmCTest::Initialize()
|
||||||
{
|
{
|
||||||
std::cerr << "Cannot create directory " << testingDir
|
std::cerr << "Cannot create directory " << testingDir
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::string tagfile = testingDir + "/TAG";
|
std::string tagfile = testingDir + "/TAG";
|
||||||
|
@ -408,6 +413,7 @@ void cmCTest::Initialize()
|
||||||
}
|
}
|
||||||
m_CurrentTag = tag;
|
m_CurrentTag = tag;
|
||||||
}
|
}
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmCTest::UpdateCTestConfiguration()
|
void cmCTest::UpdateCTestConfiguration()
|
||||||
|
@ -1042,7 +1048,7 @@ int cmCTest::BuildDirectory()
|
||||||
ofs.close();
|
ofs.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
int cc;
|
tm_VectorOfStrings::size_type cc;
|
||||||
if ( m_DartConfiguration["SourceDirectory"].size() > 20 ||
|
if ( m_DartConfiguration["SourceDirectory"].size() > 20 ||
|
||||||
m_DartConfiguration["BuildDirectory"].size() > 20 )
|
m_DartConfiguration["BuildDirectory"].size() > 20 )
|
||||||
{
|
{
|
||||||
|
@ -1090,7 +1096,24 @@ int cmCTest::BuildDirectory()
|
||||||
// Errors
|
// Errors
|
||||||
for ( cc = 0; cmCTestErrorMatches[cc]; cc ++ )
|
for ( cc = 0; cmCTestErrorMatches[cc]; cc ++ )
|
||||||
{
|
{
|
||||||
cmsys::RegularExpression re(cmCTestErrorMatches[cc]);
|
m_CustomErrorMatches.push_back(cmCTestErrorMatches[cc]);
|
||||||
|
}
|
||||||
|
for ( cc = 0; cmCTestErrorExceptions[cc]; cc ++ )
|
||||||
|
{
|
||||||
|
m_CustomErrorExceptions.push_back(cmCTestErrorExceptions[cc]);
|
||||||
|
}
|
||||||
|
for ( cc = 0; cmCTestWarningMatches[cc]; cc ++ )
|
||||||
|
{
|
||||||
|
m_CustomWarningMatches.push_back(cmCTestWarningMatches[cc]);
|
||||||
|
}
|
||||||
|
for ( cc = 0; cmCTestWarningExceptions[cc]; cc ++ )
|
||||||
|
{
|
||||||
|
m_CustomWarningExceptions.push_back(cmCTestWarningExceptions[cc]);
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( cc = 0; cc < m_CustomErrorMatches.size(); cc ++ )
|
||||||
|
{
|
||||||
|
cmsys::RegularExpression re(m_CustomErrorMatches[cc].c_str());
|
||||||
cmCTest::tm_VectorOfStrings::size_type kk;
|
cmCTest::tm_VectorOfStrings::size_type kk;
|
||||||
for ( kk = 0; kk < lines.size(); kk ++ )
|
for ( kk = 0; kk < lines.size(); kk ++ )
|
||||||
{
|
{
|
||||||
|
@ -1101,9 +1124,9 @@ int cmCTest::BuildDirectory()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Warnings
|
// Warnings
|
||||||
for ( cc = 0; cmCTestWarningMatches[cc]; cc ++ )
|
for ( cc = 0; cc < m_CustomWarningMatches.size(); cc ++ )
|
||||||
{
|
{
|
||||||
cmsys::RegularExpression re(cmCTestWarningMatches[cc]);
|
cmsys::RegularExpression re(m_CustomWarningMatches[cc].c_str());
|
||||||
cmCTest::tm_VectorOfStrings::size_type kk;
|
cmCTest::tm_VectorOfStrings::size_type kk;
|
||||||
for ( kk = 0; kk < lines.size(); kk ++ )
|
for ( kk = 0; kk < lines.size(); kk ++ )
|
||||||
{
|
{
|
||||||
|
@ -1114,9 +1137,9 @@ int cmCTest::BuildDirectory()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Errors exceptions
|
// Errors exceptions
|
||||||
for ( cc = 0; cmCTestErrorExceptions[cc]; cc ++ )
|
for ( cc = 0; cc < m_CustomErrorExceptions.size(); cc ++ )
|
||||||
{
|
{
|
||||||
cmsys::RegularExpression re(cmCTestErrorExceptions[cc]);
|
cmsys::RegularExpression re(m_CustomErrorExceptions[cc].c_str());
|
||||||
std::vector<int>::size_type kk;
|
std::vector<int>::size_type kk;
|
||||||
for ( kk =0; kk < markedLines.size(); kk ++ )
|
for ( kk =0; kk < markedLines.size(); kk ++ )
|
||||||
{
|
{
|
||||||
|
@ -1130,9 +1153,9 @@ int cmCTest::BuildDirectory()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Warning exceptions
|
// Warning exceptions
|
||||||
for ( cc = 0; cmCTestWarningExceptions[cc]; cc ++ )
|
for ( cc = 0; cc < m_CustomWarningExceptions.size(); cc ++ )
|
||||||
{
|
{
|
||||||
cmsys::RegularExpression re(cmCTestWarningExceptions[cc]);
|
cmsys::RegularExpression re(m_CustomWarningExceptions[cc].c_str());
|
||||||
std::vector<int>::size_type kk;
|
std::vector<int>::size_type kk;
|
||||||
for ( kk =0; kk < markedLines.size(); kk ++ )
|
for ( kk =0; kk < markedLines.size(); kk ++ )
|
||||||
{
|
{
|
||||||
|
@ -1818,6 +1841,52 @@ void cmCTest::ProcessDirectory(cmCTest::tm_VectorOfStrings &passed,
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if ( memcheck )
|
||||||
|
{
|
||||||
|
tm_VectorOfStrings::iterator it;
|
||||||
|
bool found = false;
|
||||||
|
for ( it = m_CustomMemCheckIgnore.begin();
|
||||||
|
it != m_CustomMemCheckIgnore.end(); ++ it )
|
||||||
|
{
|
||||||
|
if ( *it == args[0].Value )
|
||||||
|
{
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( found )
|
||||||
|
{
|
||||||
|
if ( m_Verbose )
|
||||||
|
{
|
||||||
|
std::cout << "Ignore memcheck: " << *it << std::endl;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tm_VectorOfStrings::iterator it;
|
||||||
|
bool found = false;
|
||||||
|
for ( it = m_CustomTestsIgnore.begin();
|
||||||
|
it != m_CustomTestsIgnore.end(); ++ it )
|
||||||
|
{
|
||||||
|
if ( *it == args[0].Value )
|
||||||
|
{
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( found )
|
||||||
|
{
|
||||||
|
if ( m_Verbose )
|
||||||
|
{
|
||||||
|
std::cout << "Ignore test: " << *it << std::endl;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (this->m_UseIncludeRegExp && !ireg.find(args[0].Value.c_str()))
|
if (this->m_UseIncludeRegExp && !ireg.find(args[0].Value.c_str()))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
@ -2101,6 +2170,23 @@ int cmCTest::TestDirectory(bool memcheck)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( memcheck )
|
||||||
|
{
|
||||||
|
if ( !this->ExecuteCommands(m_CustomPreMemCheck) )
|
||||||
|
{
|
||||||
|
std::cerr << "Problem executing pre-memcheck command(s)." << std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( !this->ExecuteCommands(m_CustomPreTest) )
|
||||||
|
{
|
||||||
|
std::cerr << "Problem executing pre-test command(s)." << std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cmCTest::tm_VectorOfStrings passed;
|
cmCTest::tm_VectorOfStrings passed;
|
||||||
cmCTest::tm_VectorOfStrings failed;
|
cmCTest::tm_VectorOfStrings failed;
|
||||||
int total;
|
int total;
|
||||||
|
@ -2170,6 +2256,23 @@ int cmCTest::TestDirectory(bool memcheck)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( memcheck )
|
||||||
|
{
|
||||||
|
if ( !this->ExecuteCommands(m_CustomPostMemCheck) )
|
||||||
|
{
|
||||||
|
std::cerr << "Problem executing post-memcheck command(s)." << std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( !this->ExecuteCommands(m_CustomPostTest) )
|
||||||
|
{
|
||||||
|
std::cerr << "Problem executing post-test command(s)." << std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return int(failed.size());
|
return int(failed.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3846,8 +3949,14 @@ int cmCTest::Run(std::vector<std::string>const& args, std::string* output)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this->Initialize();
|
if ( !this->Initialize() )
|
||||||
|
{
|
||||||
|
res = 12;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
res = this->ProcessTests();
|
res = this->ProcessTests();
|
||||||
|
}
|
||||||
this->Finalize();
|
this->Finalize();
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
|
@ -4296,3 +4405,85 @@ void cmCTest::SetNotesFiles(const char* notes)
|
||||||
}
|
}
|
||||||
m_NotesFiles = notes;
|
m_NotesFiles = notes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int cmCTest::ReadCustomConfigurationFileTree(const char* dir)
|
||||||
|
{
|
||||||
|
tm_VectorOfStrings dirs;
|
||||||
|
tm_VectorOfStrings ndirs;
|
||||||
|
dirs.push_back(dir);
|
||||||
|
cmake cm;
|
||||||
|
cmGlobalGenerator gg;
|
||||||
|
gg.SetCMakeInstance(&cm);
|
||||||
|
cmLocalGenerator *lg = gg.CreateLocalGenerator();
|
||||||
|
lg->SetGlobalGenerator(&gg);
|
||||||
|
cmMakefile *mf = lg->GetMakefile();
|
||||||
|
|
||||||
|
while ( dirs.size() > 0 )
|
||||||
|
{
|
||||||
|
tm_VectorOfStrings::iterator cdir = dirs.end()-1;
|
||||||
|
std::string rexpr = *cdir + "/*";
|
||||||
|
std::string fname = *cdir + "/CTestCustom.ctest";
|
||||||
|
if ( cmSystemTools::FileExists(fname.c_str()) &&
|
||||||
|
(!lg->GetMakefile()->ReadListFile(0, fname.c_str()) ||
|
||||||
|
cmSystemTools::GetErrorOccuredFlag() ) )
|
||||||
|
{
|
||||||
|
std::cerr << "Problem reading custom configuration" << std::endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
dirs.erase(dirs.end()-1, dirs.end());
|
||||||
|
cmSystemTools::SimpleGlob(rexpr, ndirs, -1);
|
||||||
|
dirs.insert(dirs.end(), ndirs.begin(), ndirs.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
this->PopulateCustomVector(mf, "CTEST_CUSTOM_ERROR_MATCH", m_CustomErrorMatches);
|
||||||
|
this->PopulateCustomVector(mf, "CTEST_CUSTOM_ERROR_EXCEPTION", m_CustomErrorExceptions);
|
||||||
|
this->PopulateCustomVector(mf, "CTEST_CUSTOM_WARNING_MATCH", m_CustomWarningMatches);
|
||||||
|
this->PopulateCustomVector(mf, "CTEST_CUSTOM_WARNING_EXCEPTION", m_CustomWarningExceptions);
|
||||||
|
|
||||||
|
this->PopulateCustomVector(mf, "CTEST_CUSTOM_TESTS_IGNORE", m_CustomTestsIgnore);
|
||||||
|
this->PopulateCustomVector(mf, "CTEST_CUSTOM_MEMCHECK_IGNORE", m_CustomMemCheckIgnore);
|
||||||
|
|
||||||
|
this->PopulateCustomVector(mf, "CTEST_CUSTOM_PRE_TEST", m_CustomPreTest);
|
||||||
|
this->PopulateCustomVector(mf, "CTEST_CUSTOM_POST_TEST", m_CustomPostTest);
|
||||||
|
this->PopulateCustomVector(mf, "CTEST_CUSTOM_PRE_MEMCHECK", m_CustomPreMemCheck);
|
||||||
|
this->PopulateCustomVector(mf, "CTEST_CUSTOM_POST_MEMCHECK", m_CustomPostMemCheck);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmCTest::PopulateCustomVector(cmMakefile* mf, const char* def, tm_VectorOfStrings& vec)
|
||||||
|
{
|
||||||
|
if ( !def)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const char* dval = mf->GetDefinition(def);
|
||||||
|
if ( !dval )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
std::vector<std::string> slist;
|
||||||
|
cmSystemTools::ExpandListArgument(dval, slist);
|
||||||
|
vec.insert(vec.end(), slist.begin(), slist.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
int cmCTest::ExecuteCommands(tm_VectorOfStrings& vec)
|
||||||
|
{
|
||||||
|
tm_VectorOfStrings::iterator it;
|
||||||
|
for ( it = vec.begin(); it != vec.end(); ++it )
|
||||||
|
{
|
||||||
|
int retVal = 0;
|
||||||
|
if ( m_Verbose )
|
||||||
|
{
|
||||||
|
std::cout << "Run command: " << *it << std::endl;
|
||||||
|
}
|
||||||
|
if ( !cmSystemTools::RunSingleCommand(it->c_str(), 0, &retVal, 0, true /*m_Verbose*/) ||
|
||||||
|
retVal != 0 )
|
||||||
|
{
|
||||||
|
std::cerr << "Problem running command: " << *it << std::endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
|
|
||||||
#include "cmStandardIncludes.h"
|
#include "cmStandardIncludes.h"
|
||||||
|
|
||||||
|
class cmMakefile;
|
||||||
|
|
||||||
class cmCTest
|
class cmCTest
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -37,7 +39,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Initialize and finalize testing
|
* Initialize and finalize testing
|
||||||
*/
|
*/
|
||||||
void Initialize();
|
int Initialize();
|
||||||
void Finalize();
|
void Finalize();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -315,6 +317,24 @@ private:
|
||||||
bool m_BuildNoCMake;
|
bool m_BuildNoCMake;
|
||||||
std::string m_NotesFiles;
|
std::string m_NotesFiles;
|
||||||
|
|
||||||
|
int ReadCustomConfigurationFileTree(const char* dir);
|
||||||
|
void PopulateCustomVector(cmMakefile* mf, const char* definition, tm_VectorOfStrings& vec);
|
||||||
|
|
||||||
|
tm_VectorOfStrings m_CustomErrorMatches;
|
||||||
|
tm_VectorOfStrings m_CustomErrorExceptions;
|
||||||
|
tm_VectorOfStrings m_CustomWarningMatches;
|
||||||
|
tm_VectorOfStrings m_CustomWarningExceptions;
|
||||||
|
|
||||||
|
tm_VectorOfStrings m_CustomTestsIgnore;
|
||||||
|
tm_VectorOfStrings m_CustomMemCheckIgnore;
|
||||||
|
|
||||||
|
tm_VectorOfStrings m_CustomPreTest;
|
||||||
|
tm_VectorOfStrings m_CustomPostTest;
|
||||||
|
tm_VectorOfStrings m_CustomPreMemCheck;
|
||||||
|
tm_VectorOfStrings m_CustomPostMemCheck;
|
||||||
|
|
||||||
|
int ExecuteCommands(tm_VectorOfStrings& vec);
|
||||||
|
|
||||||
//! Reread the configuration file
|
//! Reread the configuration file
|
||||||
void UpdateCTestConfiguration();
|
void UpdateCTestConfiguration();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue