ENH: added -U option to take union of -R and -I

This commit is contained in:
Ken Martin 2004-11-13 09:55:31 -05:00
parent 247c367a59
commit 5a0366c6e0
4 changed files with 92 additions and 50 deletions

View File

@ -193,7 +193,8 @@ cmCTestTestHandler::cmCTestTestHandler()
{
m_Verbose = false;
m_CTest = 0;
m_UseUnion = false;
m_UseIncludeRegExp = false;
m_UseExcludeRegExp = false;
m_UseExcludeRegExpFirst = false;
@ -381,15 +382,36 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<cmStdString> &passed,
<< std::endl;
}
// expand the test list
this->ExpandTestsToRunInformation((int)tmsize);
// how many tests are in based on RegExp?
int inREcnt = 0;
tm_ListOfTests::iterator it;
for ( it = testlist.begin(); it != testlist.end(); it ++ )
{
if (it->m_IsInBasedOnREOptions)
{
inREcnt ++;
}
}
// expand the test list based on the union flag
if (m_UseUnion)
{
this->ExpandTestsToRunInformation((int)tmsize);
}
else
{
this->ExpandTestsToRunInformation(inREcnt);
}
int cnt = 0;
tm_ListOfTests::iterator it;
inREcnt = 0;
std::string last_directory = "";
for ( it = testlist.begin(); it != testlist.end(); it ++ )
{
cnt ++;
if (it->m_IsInBasedOnREOptions)
{
inREcnt++;
}
const std::string& testname = it->m_Name;
tm_VectorOfListFileArgs& args = it->m_Args;
cmCTestTestResult cres;
@ -408,30 +430,41 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<cmStdString> &passed,
}
cres.m_Name = testname;
cres.m_Path = it->m_Directory.c_str();
if(m_TestsToRun.size() &&
std::find(m_TestsToRun.begin(), m_TestsToRun.end(), cnt) == m_TestsToRun.end())
if (m_UseUnion)
{
continue;
// if it is not in the list and not in the regexp then skip
if ((m_TestsToRun.size() &&
std::find(m_TestsToRun.begin(), m_TestsToRun.end(), cnt)
== m_TestsToRun.end()) && !it->m_IsInBasedOnREOptions)
{
continue;
}
}
else
{
// is this test in the list of tests to run? If not then skip it
if ((m_TestsToRun.size() &&
std::find(m_TestsToRun.begin(), m_TestsToRun.end(), inREcnt)
== m_TestsToRun.end()) || !it->m_IsInBasedOnREOptions)
{
continue;
}
}
std::cerr.width(3);
std::cerr << cnt << "/";
std::cerr.width(3);
std::cerr << tmsize << " Testing ";
std::string outname = testname;
outname.resize(30, ' ');
if ( m_CTest->GetShowOnly() )
{
std::cerr.width(3);
std::cerr << cnt << "/";
std::cerr.width(3);
std::cerr << tmsize << " Testing ";
std::string outname = testname;
outname.resize(30, ' ');
std::cerr << outname.c_str() << "\n";
}
}
else
{
std::cerr.width(3);
std::cerr << cnt << "/";
std::cerr.width(3);
std::cerr << tmsize << " Testing ";
std::string outname = testname;
outname.resize(30, ' ');
std::cerr << outname.c_str();
std::cerr.flush();
}
@ -1121,22 +1154,21 @@ void cmCTestTestHandler::GetListOfTests(tm_ListOfTests* testlist,
}
}
if (this->m_UseIncludeRegExp && !ireg.find(testname.c_str()))
{
continue;
}
if (this->m_UseExcludeRegExp &&
!this->m_UseExcludeRegExpFirst &&
ereg.find(testname.c_str()))
{
continue;
}
cmCTestTestProperties test;
test.m_Name = testname;
test.m_Args = args;
test.m_Directory = cmSystemTools::GetCurrentWorkingDirectory();
test.m_IsInBasedOnREOptions = true;
if (this->m_UseIncludeRegExp && !ireg.find(testname.c_str()))
{
test.m_IsInBasedOnREOptions = false;
}
else if (this->m_UseExcludeRegExp &&
!this->m_UseExcludeRegExpFirst &&
ereg.find(testname.c_str()))
{
test.m_IsInBasedOnREOptions = false;
}
testlist->push_back(test);
}
}
@ -1244,12 +1276,6 @@ void cmCTestTestHandler::ExpandTestsToRunInformation(int numTests)
std::vector<int>::iterator new_end =
std::unique(m_TestsToRun.begin(), m_TestsToRun.end());
m_TestsToRun.erase(new_end, m_TestsToRun.end());
std::cout << "Running tests: ";
for(unsigned int i =0; i < m_TestsToRun.size(); ++i)
{
std::cout << m_TestsToRun[i] << " ";
}
std::cout << "\n";
}
#define SPACE_REGEX "[ \t\r\n]"

View File

@ -42,9 +42,16 @@ public:
* If verbose then more informaiton is printed out
*/
void SetVerbose(bool val) { m_Verbose = val; }
void PopulateCustomVectors(cmMakefile *mf);
/*
* When both -R and -I are used should te resulting test list be the
* intersection or the union of the lists. By default it is the
* intersection.
*/
void SetUseUnion(bool val) { m_UseUnion = val; }
void PopulateCustomVectors(cmMakefile *mf);
///! Control the use of the regular expresisons, call these methods to turn
///them on
void UseIncludeRegExp();
@ -58,7 +65,7 @@ public:
void SetTestsToRunInformation(const char*);
typedef std::vector<cmListFileArgument> tm_VectorOfListFileArgs;
private:
enum { // Memory checkers
@ -152,13 +159,14 @@ private:
void ProcessDirectory(std::vector<cmStdString> &passed,
std::vector<cmStdString> &failed,
bool memcheck);
struct cmCTestTestProperties
{
{
cmStdString m_Name;
cmStdString m_Directory;
tm_VectorOfListFileArgs m_Args;
};
bool m_IsInBasedOnREOptions;
};
typedef std::vector<cmCTestTestProperties> tm_ListOfTests;
/**
@ -205,7 +213,7 @@ private:
std::string& log, int* results);
std::string TestsToRunString;
bool m_UseUnion;
};
#endif

View File

@ -1453,6 +1453,10 @@ int cmCTest::Run(std::vector<std::string>const& args, std::string* output)
i++;
this->TestHandler->SetTestsToRunInformation(args[i].c_str());
}
if(arg.find("-U",0) == 0)
{
this->TestHandler->SetUseUnion(true);
}
if(arg.find("-R",0) == 0 && i < args.size() - 1)
{
this->TestHandler->UseIncludeRegExp();

View File

@ -81,11 +81,15 @@ static const cmDocumentationEntry cmDocumentationOptions[] =
"appropriate options."},
{"-A <Notes file>", "Add a notes file with submission",
"This option tells ctest to include a notes file when submitting dashboard. "},
{"-I [Start,End,Stride,test#,test#|Test file]", "Run a specific number of tests by number.",
"This option causes ctest to run tests starting at number Start, ending at number End, "
"and incrementing by Stride. Any additional numbers after Stride are considered individual "
"test numbers. Start, End,or stride can be empty. Optionally a file can be given that contains "
"the same syntax as the command line."},
{"-I [Start,End,Stride,test#,test#|Test file]",
"Run a specific number of tests by number.",
"This option causes ctest to run tests starting at number Start, ending "
"at number End, and incrementing by Stride. Any additional numbers after "
"Stride are considered individual test numbers. Start, End,or stride "
"can be empty. Optionally a file can be given that contains the same "
"syntax as the command line."},
{"-U", "When both -R and -I are specified by default the intersection of "
"tests are run. By specifying -U the union of tests is run instead."},
{"--interactive-debug-mode [0|1]", "Set the interactive mode to 0 or 1.",
"This option causes ctest to run tests in either an interactive mode or a non-interactive mode. "
"On Windows this means that in non-interactive mode, all system debug pop up windows are blocked. "