summaryrefslogtreecommitdiffstats
path: root/Source/CTest/cmCTestTestHandler.cxx
diff options
context:
space:
mode:
authorZach Mullen <zach.mullen@kitware.com>2009-10-29 19:30:12 (GMT)
committerZach Mullen <zach.mullen@kitware.com>2009-10-29 19:30:12 (GMT)
commit8612aa10b681fb31bcf3e4959b151fc7f3a5442e (patch)
tree60854e460425b7becc46e2ca93f9626a4262f2f1 /Source/CTest/cmCTestTestHandler.cxx
parente183581b1459aba72758f395d7e1b74ff8f6aade (diff)
downloadCMake-8612aa10b681fb31bcf3e4959b151fc7f3a5442e.zip
CMake-8612aa10b681fb31bcf3e4959b151fc7f3a5442e.tar.gz
CMake-8612aa10b681fb31bcf3e4959b151fc7f3a5442e.tar.bz2
Hook for scheduling tests in a random order
This may help statistically detect implicit dependencies among unit tests while running in parallel.
Diffstat (limited to 'Source/CTest/cmCTestTestHandler.cxx')
-rw-r--r--Source/CTest/cmCTestTestHandler.cxx18
1 files changed, 17 insertions, 1 deletions
diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx
index 3572b11..56ddec7 100644
--- a/Source/CTest/cmCTestTestHandler.cxx
+++ b/Source/CTest/cmCTestTestHandler.cxx
@@ -491,11 +491,16 @@ int cmCTestTestHandler::ProcessHandler()
{
// Update internal data structure from generic one
this->SetTestsToRunInformation(this->GetOption("TestsToRunInformation"));
- this->SetUseUnion(cmSystemTools::IsOn(this->GetOption("UseUnion")));
+ this->SetUseUnion(cmSystemTools::IsOn(this->GetOption("UseUnion")));
+ if(cmSystemTools::IsOn(this->GetOption("ScheduleRandom")))
+ {
+ this->CTest->SetScheduleType("Random");
+ }
if(this->GetOption("ParallelLevel"))
{
this->CTest->SetParallelLevel(atoi(this->GetOption("ParallelLevel")));
}
+
const char* val;
val = this->GetOption("LabelRegularExpression");
if ( val )
@@ -1021,12 +1026,23 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<cmStdString> &passed,
cmCTestMultiProcessHandler::TestMap tests;
cmCTestMultiProcessHandler::PropertiesMap properties;
+ bool randomSchedule = this->CTest->GetScheduleType() == "Random";
+ if(randomSchedule)
+ {
+ srand((unsigned)time(0));
+ }
+
for (ListOfTests::iterator it = this->TestList.begin();
it != this->TestList.end(); ++it)
{
cmCTestTestProperties& p = *it;
cmCTestMultiProcessHandler::TestSet depends;
+ if(randomSchedule)
+ {
+ p.Cost = rand();
+ }
+
if(p.Depends.size())
{
for(std::vector<std::string>::iterator i = p.Depends.begin();