ENH: added -U option to take union of -R and -I
This commit is contained in:
parent
247c367a59
commit
5a0366c6e0
@ -193,7 +193,8 @@ cmCTestTestHandler::cmCTestTestHandler()
|
|||||||
{
|
{
|
||||||
m_Verbose = false;
|
m_Verbose = false;
|
||||||
m_CTest = 0;
|
m_CTest = 0;
|
||||||
|
m_UseUnion = false;
|
||||||
|
|
||||||
m_UseIncludeRegExp = false;
|
m_UseIncludeRegExp = false;
|
||||||
m_UseExcludeRegExp = false;
|
m_UseExcludeRegExp = false;
|
||||||
m_UseExcludeRegExpFirst = false;
|
m_UseExcludeRegExpFirst = false;
|
||||||
@ -381,15 +382,36 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<cmStdString> &passed,
|
|||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// expand the test list
|
// how many tests are in based on RegExp?
|
||||||
this->ExpandTestsToRunInformation((int)tmsize);
|
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;
|
int cnt = 0;
|
||||||
tm_ListOfTests::iterator it;
|
inREcnt = 0;
|
||||||
std::string last_directory = "";
|
std::string last_directory = "";
|
||||||
for ( it = testlist.begin(); it != testlist.end(); it ++ )
|
for ( it = testlist.begin(); it != testlist.end(); it ++ )
|
||||||
{
|
{
|
||||||
cnt ++;
|
cnt ++;
|
||||||
|
if (it->m_IsInBasedOnREOptions)
|
||||||
|
{
|
||||||
|
inREcnt++;
|
||||||
|
}
|
||||||
const std::string& testname = it->m_Name;
|
const std::string& testname = it->m_Name;
|
||||||
tm_VectorOfListFileArgs& args = it->m_Args;
|
tm_VectorOfListFileArgs& args = it->m_Args;
|
||||||
cmCTestTestResult cres;
|
cmCTestTestResult cres;
|
||||||
@ -408,30 +430,41 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<cmStdString> &passed,
|
|||||||
}
|
}
|
||||||
cres.m_Name = testname;
|
cres.m_Name = testname;
|
||||||
cres.m_Path = it->m_Directory.c_str();
|
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() )
|
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";
|
std::cerr << outname.c_str() << "\n";
|
||||||
}
|
}
|
||||||
else
|
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 << outname.c_str();
|
||||||
std::cerr.flush();
|
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;
|
cmCTestTestProperties test;
|
||||||
test.m_Name = testname;
|
test.m_Name = testname;
|
||||||
test.m_Args = args;
|
test.m_Args = args;
|
||||||
test.m_Directory = cmSystemTools::GetCurrentWorkingDirectory();
|
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);
|
testlist->push_back(test);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1244,12 +1276,6 @@ void cmCTestTestHandler::ExpandTestsToRunInformation(int numTests)
|
|||||||
std::vector<int>::iterator new_end =
|
std::vector<int>::iterator new_end =
|
||||||
std::unique(m_TestsToRun.begin(), m_TestsToRun.end());
|
std::unique(m_TestsToRun.begin(), m_TestsToRun.end());
|
||||||
m_TestsToRun.erase(new_end, 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]"
|
#define SPACE_REGEX "[ \t\r\n]"
|
||||||
|
@ -42,9 +42,16 @@ public:
|
|||||||
* If verbose then more informaiton is printed out
|
* If verbose then more informaiton is printed out
|
||||||
*/
|
*/
|
||||||
void SetVerbose(bool val) { m_Verbose = val; }
|
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
|
///! Control the use of the regular expresisons, call these methods to turn
|
||||||
///them on
|
///them on
|
||||||
void UseIncludeRegExp();
|
void UseIncludeRegExp();
|
||||||
@ -58,7 +65,7 @@ public:
|
|||||||
void SetTestsToRunInformation(const char*);
|
void SetTestsToRunInformation(const char*);
|
||||||
|
|
||||||
typedef std::vector<cmListFileArgument> tm_VectorOfListFileArgs;
|
typedef std::vector<cmListFileArgument> tm_VectorOfListFileArgs;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
enum { // Memory checkers
|
enum { // Memory checkers
|
||||||
@ -152,13 +159,14 @@ private:
|
|||||||
void ProcessDirectory(std::vector<cmStdString> &passed,
|
void ProcessDirectory(std::vector<cmStdString> &passed,
|
||||||
std::vector<cmStdString> &failed,
|
std::vector<cmStdString> &failed,
|
||||||
bool memcheck);
|
bool memcheck);
|
||||||
|
|
||||||
struct cmCTestTestProperties
|
struct cmCTestTestProperties
|
||||||
{
|
{
|
||||||
cmStdString m_Name;
|
cmStdString m_Name;
|
||||||
cmStdString m_Directory;
|
cmStdString m_Directory;
|
||||||
tm_VectorOfListFileArgs m_Args;
|
tm_VectorOfListFileArgs m_Args;
|
||||||
};
|
bool m_IsInBasedOnREOptions;
|
||||||
|
};
|
||||||
|
|
||||||
typedef std::vector<cmCTestTestProperties> tm_ListOfTests;
|
typedef std::vector<cmCTestTestProperties> tm_ListOfTests;
|
||||||
/**
|
/**
|
||||||
@ -205,7 +213,7 @@ private:
|
|||||||
std::string& log, int* results);
|
std::string& log, int* results);
|
||||||
|
|
||||||
std::string TestsToRunString;
|
std::string TestsToRunString;
|
||||||
|
bool m_UseUnion;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1453,6 +1453,10 @@ int cmCTest::Run(std::vector<std::string>const& args, std::string* output)
|
|||||||
i++;
|
i++;
|
||||||
this->TestHandler->SetTestsToRunInformation(args[i].c_str());
|
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)
|
if(arg.find("-R",0) == 0 && i < args.size() - 1)
|
||||||
{
|
{
|
||||||
this->TestHandler->UseIncludeRegExp();
|
this->TestHandler->UseIncludeRegExp();
|
||||||
|
@ -81,11 +81,15 @@ static const cmDocumentationEntry cmDocumentationOptions[] =
|
|||||||
"appropriate options."},
|
"appropriate options."},
|
||||||
{"-A <Notes file>", "Add a notes file with submission",
|
{"-A <Notes file>", "Add a notes file with submission",
|
||||||
"This option tells ctest to include a notes file when submitting dashboard. "},
|
"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.",
|
{"-I [Start,End,Stride,test#,test#|Test file]",
|
||||||
"This option causes ctest to run tests starting at number Start, ending at number End, "
|
"Run a specific number of tests by number.",
|
||||||
"and incrementing by Stride. Any additional numbers after Stride are considered individual "
|
"This option causes ctest to run tests starting at number Start, ending "
|
||||||
"test numbers. Start, End,or stride can be empty. Optionally a file can be given that contains "
|
"at number End, and incrementing by Stride. Any additional numbers after "
|
||||||
"the same syntax as the command line."},
|
"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.",
|
{"--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. "
|
"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. "
|
"On Windows this means that in non-interactive mode, all system debug pop up windows are blocked. "
|
||||||
|
Loading…
x
Reference in New Issue
Block a user