| 940 | } |
| 941 | |
| 942 | void 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 |
no test coverage detected