Skip to content

Commit fbd8ee4

Browse files
authored
Merge pull request #48787 from wddgit/fixProcessingOrderMerge
Fix corner case in processingOrderMerge
2 parents 4b4378d + b792a71 commit fbd8ee4

File tree

3 files changed

+13
-16
lines changed

3 files changed

+13
-16
lines changed

DataFormats/Provenance/interface/processingOrderMerge.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ namespace edm {
1919
*/
2020
void processingOrderMerge(std::vector<std::string> const& iFrom, std::vector<std::string>& iTo);
2121
} // namespace edm
22-
#endif
22+
#endif

DataFormats/Provenance/src/processingOrderMerge.cc

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ namespace edm {
1313
template <typename Iter>
1414
Iter foundLaterIn(Iter itBegin, Iter it, Iter itEnd, std::string const& name) {
1515
auto itFind = std::find(itBegin, itEnd, name);
16+
// Sanity check, it should be impossible for this to happen
1617
if (itFind < it) {
1718
throwIncompatibleOrdering("process " + name + " found earlier in other list");
1819
}
@@ -56,28 +57,17 @@ namespace edm {
5657
auto itFindNew = foundLaterIn(iHistory.begin(), itNew, itNewEnd, *itOld);
5758
if (itFindOld != itOldEnd) {
5859
if (itFindNew != itNewEnd) {
59-
throwIncompatibleOrdering("process " + *itNew + " and " + *itOld + " are out of order");
60-
}
61-
//found it, copy over everything up to and including it
62-
while (itOld != itFindOld) {
63-
tempNames.push_back(*itOld);
64-
++itOld;
60+
throwIncompatibleOrdering("order of processes " + *itNew + " and " + *itOld +
61+
" is not the same in all ProcessHistories");
6562
}
6663
tempNames.push_back(*itOld);
6764
++itOld;
68-
++itNew;
6965
} else {
7066
if (itFindNew == itNewEnd) {
71-
throwIncompatibleOrdering("process " + *itOld + " and " + *itNew + " are independent");
67+
throwIncompatibleOrdering("order of processes " + *itOld + " and " + *itNew + " is ambiguous");
7268
}
73-
while (itNew != itFindNew) {
74-
tempNames.push_back(*itNew);
75-
++itNew;
76-
}
77-
//not found, add the new one
7869
tempNames.push_back(*itNew);
7970
++itNew;
80-
++itOld;
8171
}
8272
}
8373
}

DataFormats/Provenance/test/processingOrderMerge_t.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,13 @@ TEST_CASE("processingOrderMerge", "[processingOrderMerge]") {
167167
std::vector<std::string> names = {"D", "B", "C", "A"};
168168
REQUIRE_THROWS_AS(edm::processingOrderMerge(ph, names), cms::Exception);
169169
}
170+
SECTION("reverse order with an extra one in front") {
171+
edm::ProcessHistory ph;
172+
ph.emplace_back("C", edm::ReleaseVersion(""), edm::HardwareResourcesDescription());
173+
ph.emplace_back("A", edm::ReleaseVersion(""), edm::HardwareResourcesDescription());
174+
std::vector<std::string> names = {"B", "C", "A"};
175+
REQUIRE_THROWS_AS(edm::processingOrderMerge(ph, names), cms::Exception);
176+
}
170177
}
171178
}
172-
}
179+
}

0 commit comments

Comments
 (0)