summaryrefslogtreecommitdiffstats
path: root/Source/CTest/cmCTestMultiProcessHandler.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2010-12-15 21:49:34 (GMT)
committerBrad King <brad.king@kitware.com>2010-12-15 21:49:34 (GMT)
commitf48d3bc5ba69906ee3c61ddb103a91bf6467c86d (patch)
tree23d97fa05e6bc27310d8be7cbb5a0fc94df7efba /Source/CTest/cmCTestMultiProcessHandler.cxx
parenta14a8562ea5f321b0a8f6f61f4c457da298825c5 (diff)
downloadCMake-f48d3bc5ba69906ee3c61ddb103a91bf6467c86d.zip
CMake-f48d3bc5ba69906ee3c61ddb103a91bf6467c86d.tar.gz
CMake-f48d3bc5ba69906ee3c61ddb103a91bf6467c86d.tar.bz2
CTest: Fix test DEPEND cycle detection
A cycle exists when the DFS returns to the root node, not just when multiple paths lead to the same node. Inspired-By: Alexander Esilevich <aesilevich@pathscale.com>
Diffstat (limited to 'Source/CTest/cmCTestMultiProcessHandler.cxx')
-rw-r--r--Source/CTest/cmCTestMultiProcessHandler.cxx37
1 files changed, 21 insertions, 16 deletions
diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx
index 93c2963..ca26c98 100644
--- a/Source/CTest/cmCTestMultiProcessHandler.cxx
+++ b/Source/CTest/cmCTestMultiProcessHandler.cxx
@@ -653,32 +653,37 @@ bool cmCTestMultiProcessHandler::CheckCycles()
it != this->Tests.end(); ++it)
{
//DFS from each element to itself
+ int root = it->first;
+ std::set<int> visited;
std::stack<int> s;
- std::vector<int> visited;
-
- s.push(it->first);
-
+ s.push(root);
while(!s.empty())
{
int test = s.top();
s.pop();
-
- for(TestSet::iterator d = this->Tests[test].begin();
- d != this->Tests[test].end(); ++d)
+ if(visited.insert(test).second)
{
- if(std::find(visited.begin(), visited.end(), *d) != visited.end())
+ for(TestSet::iterator d = this->Tests[test].begin();
+ d != this->Tests[test].end(); ++d)
{
- //cycle exists
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Error: a cycle exists in "
- "the test dependency graph for the test \""
- << this->Properties[it->first]->Name << "\"." << std::endl
- << "Please fix the cycle and run ctest again." << std::endl);
- return false;
+ if(*d == root)
+ {
+ //cycle exists
+ cmCTestLog(this->CTest, ERROR_MESSAGE, "Error: a cycle exists in "
+ "the test dependency graph for the test \""
+ << this->Properties[root]->Name << "\"." << std::endl
+ << "Please fix the cycle and run ctest again." << std::endl);
+ return false;
+ }
+ else
+ {
+ s.push(*d);
+ }
}
- s.push(*d);
}
- visited.push_back(test);
}
}
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "Checking test dependency graph end" << std::endl);
return true;
}