MCPcopy Create free account
hub / github.com/Kitware/CMake / CreateParallelTestCostList

Method CreateParallelTestCostList

Source/CTest/cmCTestMultiProcessHandler.cxx:942–998  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

940}
941
942void cmCTestMultiProcessHandler::CreateParallelTestCostList()
943{
944 TestSet alreadyOrderedTests;
945
946 std::list<TestSet> priorityStack;
947 priorityStack.emplace_back();
948 TestSet& topLevel = priorityStack.back();
949
950 // In parallel test runs add previously failed tests to the front
951 // of the cost list and queue other tests for further sorting
952 for (auto const& t : this->PendingTests) {
953 if (cm::contains(this->LastTestsFailed, this->Properties[t.first]->Name)) {
954 // If the test failed last time, it should be run first.
955 this->OrderedTests.push_back(t.first);
956 alreadyOrderedTests.insert(t.first);
957 } else {
958 topLevel.insert(t.first);
959 }
960 }
961
962 // In parallel test runs repeatedly move dependencies of the tests on
963 // the current dependency level to the next level until no
964 // further dependencies exist.
965 while (!priorityStack.back().empty()) {
966 TestSet& previousSet = priorityStack.back();
967 priorityStack.emplace_back();
968 TestSet& currentSet = priorityStack.back();
969
970 for (auto const& i : previousSet) {
971 TestSet const& dependencies = this->PendingTests[i].Depends;
972 currentSet.insert(dependencies.begin(), dependencies.end());
973 }
974
975 for (auto const& i : currentSet) {
976 previousSet.erase(i);
977 }
978 }
979
980 // Remove the empty dependency level
981 priorityStack.pop_back();
982
983 // Reverse iterate over the different dependency levels (deepest first).
984 // Sort tests within each level by COST and append them to the cost list.
985 for (TestSet const& currentSet : cmReverseRange(priorityStack)) {
986 TestList sortedCopy;
987 cm::append(sortedCopy, currentSet);
988 std::stable_sort(sortedCopy.begin(), sortedCopy.end(),
989 TestComparator(this));
990
991 for (auto const& j : sortedCopy) {
992 if (!cm::contains(alreadyOrderedTests, j)) {
993 this->OrderedTests.push_back(j);
994 alreadyOrderedTests.insert(j);
995 }
996 }
997 }
998}
999

Callers 1

CreateTestCostListMethod · 0.95

Calls 12

cmReverseRangeFunction · 0.85
appendFunction · 0.85
TestComparatorClass · 0.85
emplace_backMethod · 0.80
push_backMethod · 0.80
eraseMethod · 0.80
pop_backMethod · 0.80
backMethod · 0.45
insertMethod · 0.45
emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected