summaryrefslogtreecommitdiffstats
path: root/Source/CTest
diff options
context:
space:
mode:
authorNils Gladitz <nilsgladitz@gmail.com>2013-12-20 21:44:37 (GMT)
committerNils Gladitz <nilsgladitz@gmail.com>2013-12-23 14:31:15 (GMT)
commit7f0d4aff24cbb7ea9336a484f6ad8f73a63ac77f (patch)
tree9b14d2960bf92f1de54286f5e85e0a86369c8c5d /Source/CTest
parent6820882be57942403fa7eaf706a0169fd2816fc2 (diff)
downloadCMake-7f0d4aff24cbb7ea9336a484f6ad8f73a63ac77f.zip
CMake-7f0d4aff24cbb7ea9336a484f6ad8f73a63ac77f.tar.gz
CMake-7f0d4aff24cbb7ea9336a484f6ad8f73a63ac77f.tar.bz2
CTest: fix regressions introduced by the ctest-fix-run-serial topic
The first regression resulted in endless looping due to unrun test dependencies. The second regression prioritized all tests with dependencies in serial test runs.
Diffstat (limited to 'Source/CTest')
-rw-r--r--Source/CTest/cmCTestMultiProcessHandler.cxx87
-rw-r--r--Source/CTest/cmCTestMultiProcessHandler.h6
2 files changed, 89 insertions, 4 deletions
diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx
index 4c39d10..729f14a 100644
--- a/Source/CTest/cmCTestMultiProcessHandler.cxx
+++ b/Source/CTest/cmCTestMultiProcessHandler.cxx
@@ -139,6 +139,13 @@ void cmCTestMultiProcessHandler::StartTestProcess(int test)
}
else
{
+
+ for(TestMap::iterator j = this->Tests.begin();
+ j != this->Tests.end(); ++j)
+ {
+ j->second.erase(test);
+ }
+
this->UnlockResources(test);
this->Completed++;
this->TestFinishMap[test] = true;
@@ -441,6 +448,19 @@ int cmCTestMultiProcessHandler::SearchByName(std::string name)
//---------------------------------------------------------
void cmCTestMultiProcessHandler::CreateTestCostList()
{
+ if(this->ParallelLevel > 1)
+ {
+ CreateParallelTestCostList();
+ }
+ else
+ {
+ CreateSerialTestCostList();
+ }
+}
+
+//---------------------------------------------------------
+void cmCTestMultiProcessHandler::CreateParallelTestCostList()
+{
TestSet alreadySortedTests;
std::list<TestSet> priorityStack;
@@ -452,8 +472,7 @@ void cmCTestMultiProcessHandler::CreateTestCostList()
for(TestMap::const_iterator i = this->Tests.begin();
i != this->Tests.end(); ++i)
{
- if(this->ParallelLevel > 1 &&
- std::find(this->LastTestsFailed.begin(), this->LastTestsFailed.end(),
+ if(std::find(this->LastTestsFailed.begin(), this->LastTestsFailed.end(),
this->Properties[i->first]->Name) != this->LastTestsFailed.end())
{
//If the test failed last time, it should be run first.
@@ -466,8 +485,9 @@ void cmCTestMultiProcessHandler::CreateTestCostList()
}
}
- // Repeatedly move dependencies of the tests on the current dependency level
- // to the next level until no further dependencies exist.
+ // In parallel test runs repeatedly move dependencies of the tests on
+ // the current dependency level to the next level until no
+ // further dependencies exist.
while(priorityStack.back().size())
{
TestSet &previousSet = priorityStack.back();
@@ -526,6 +546,65 @@ void cmCTestMultiProcessHandler::CreateTestCostList()
}
//---------------------------------------------------------
+void cmCTestMultiProcessHandler::GetAllTestDependencies(
+ int test, TestList& dependencies)
+{
+ TestSet const& dependencySet = this->Tests[test];
+ for(TestSet::const_iterator i = dependencySet.begin();
+ i != dependencySet.end(); ++i)
+ {
+ GetAllTestDependencies(*i, dependencies);
+ dependencies.push_back(*i);
+ }
+}
+
+//---------------------------------------------------------
+void cmCTestMultiProcessHandler::CreateSerialTestCostList()
+{
+ TestList presortedList;
+
+ for(TestMap::iterator i = this->Tests.begin();
+ i != this->Tests.end(); ++i)
+ {
+ presortedList.push_back(i->first);
+ }
+
+ TestComparator comp(this);
+ std::stable_sort(presortedList.begin(), presortedList.end(), comp);
+
+ TestSet alreadySortedTests;
+
+ for(TestList::const_iterator i = presortedList.begin();
+ i != presortedList.end(); ++i)
+ {
+ int test = *i;
+
+ if(alreadySortedTests.find(test) != alreadySortedTests.end())
+ {
+ continue;
+ }
+
+ TestList dependencies;
+ GetAllTestDependencies(test, dependencies);
+
+ for(TestList::const_iterator j = dependencies.begin();
+ j != dependencies.end(); ++j)
+ {
+ int testDependency = *j;
+
+ if(alreadySortedTests.find(testDependency) == alreadySortedTests.end())
+ {
+ alreadySortedTests.insert(testDependency);
+ this->SortedTests.push_back(testDependency);
+ }
+ }
+
+ alreadySortedTests.insert(test);
+ this->SortedTests.push_back(test);
+ }
+}
+
+//---------------------------------------------------------
void cmCTestMultiProcessHandler::WriteCheckpoint(int index)
{
std::string fname = this->CTest->GetBinaryDir()
diff --git a/Source/CTest/cmCTestMultiProcessHandler.h b/Source/CTest/cmCTestMultiProcessHandler.h
index 439a8f3..1b53ec7 100644
--- a/Source/CTest/cmCTestMultiProcessHandler.h
+++ b/Source/CTest/cmCTestMultiProcessHandler.h
@@ -72,6 +72,12 @@ protected:
int SearchByName(std::string name);
void CreateTestCostList();
+
+ void GetAllTestDependencies(int test, TestList& dependencies);
+ void CreateSerialTestCostList();
+
+ void CreateParallelTestCostList();
+
// Removes the checkpoint file
void MarkFinished();
void EraseTest(int index);