diff options
author | Zach Mullen <zach.mullen@kitware.com> | 2009-10-29 19:30:12 (GMT) |
---|---|---|
committer | Zach Mullen <zach.mullen@kitware.com> | 2009-10-29 19:30:12 (GMT) |
commit | 8612aa10b681fb31bcf3e4959b151fc7f3a5442e (patch) | |
tree | 60854e460425b7becc46e2ca93f9626a4262f2f1 /Source/CTest/cmCTestTestHandler.cxx | |
parent | e183581b1459aba72758f395d7e1b74ff8f6aade (diff) | |
download | CMake-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.cxx | 18 |
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(); |