Skip to content

Commit b792a71

Browse files
committed
Fix corner case in processingOrderMerge
1 parent 763da79 commit b792a71

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
@@ -12,6 +12,7 @@ namespace edm {
1212
template <typename Iter>
1313
Iter foundLaterIn(Iter itBegin, Iter it, Iter itEnd, std::string const& name) {
1414
auto itFind = std::find(itBegin, itEnd, name);
15+
// Sanity check, it should be impossible for this to happen
1516
if (itFind < it) {
1617
throwIncompatibleOrdering("process " + name + " found earlier in other list");
1718
}
@@ -55,28 +56,17 @@ namespace edm {
5556
auto itFindNew = foundLaterIn(iHistory.begin(), itNew, itNewEnd, *itOld);
5657
if (itFindOld != itOldEnd) {
5758
if (itFindNew != itNewEnd) {
58-
throwIncompatibleOrdering("process " + *itNew + " and " + *itOld + " are out of order");
59-
}
60-
//found it, copy over everything up to and including it
61-
while (itOld != itFindOld) {
62-
tempNames.push_back(*itOld);
63-
++itOld;
59+
throwIncompatibleOrdering("order of processes " + *itNew + " and " + *itOld +
60+
" is not the same in all ProcessHistories");
6461
}
6562
tempNames.push_back(*itOld);
6663
++itOld;
67-
++itNew;
6864
} else {
6965
if (itFindNew == itNewEnd) {
70-
throwIncompatibleOrdering("process " + *itOld + " and " + *itNew + " are independent");
66+
throwIncompatibleOrdering("order of processes " + *itOld + " and " + *itNew + " is ambiguous");
7167
}
72-
while (itNew != itFindNew) {
73-
tempNames.push_back(*itNew);
74-
++itNew;
75-
}
76-
//not found, add the new one
7768
tempNames.push_back(*itNew);
7869
++itNew;
79-
++itOld;
8070
}
8171
}
8272
}

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)