CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
edmtest::PathsAndConsumesOfModulesTestService Class Reference

Public Member Functions

 PathsAndConsumesOfModulesTestService (edm::ParameterSet const &pset, edm::ActivityRegistry &iRegistry)
 
void preBeginJob (edm::PathsAndConsumesOfModulesBase const &pathsAndConsumes, edm::ProcessContext const &) const
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Attributes

std::vector< std::pair< std::string, std::vector< std::string > > > modulesConsumes_
 

Detailed Description

Definition at line 13 of file PathsAndConsumesOfModulesTestService.cc.

Constructor & Destructor Documentation

◆ PathsAndConsumesOfModulesTestService()

edmtest::PathsAndConsumesOfModulesTestService::PathsAndConsumesOfModulesTestService ( edm::ParameterSet const &  pset,
edm::ActivityRegistry iRegistry 
)
inline

Definition at line 15 of file PathsAndConsumesOfModulesTestService.cc.

References preBeginJob(), and edm::ActivityRegistry::watchPreBeginJob().

16  : modulesConsumes_(pset.getParameter<decltype(modulesConsumes_)>("modulesAndConsumes")) {
18  }
std::vector< std::pair< std::string, std::vector< std::string > > > modulesConsumes_
void preBeginJob(edm::PathsAndConsumesOfModulesBase const &pathsAndConsumes, edm::ProcessContext const &) const
void watchPreBeginJob(PreBeginJob::slot_type const &iSlot)
convenience function for attaching to signal

Member Function Documentation

◆ fillDescriptions()

static void edmtest::PathsAndConsumesOfModulesTestService::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
inlinestatic

Definition at line 20 of file PathsAndConsumesOfModulesTestService.cc.

References edm::ParameterSetDescription::add(), edm::ConfigurationDescriptions::addWithDefaultLabel(), submitPVResolutionJobs::desc, edm::ConfigurationDescriptions::setComment(), and AlCaHLTBitMon_QueryRunRegistry::string.

20  {
22 
24  validator.add<std::string>("key");
25  validator.add<std::vector<std::string>>("value");
26  desc.addVPSet("modulesAndConsumes", validator, std::vector<edm::ParameterSet>());
27 
28  descriptions.addWithDefaultLabel(desc);
29  descriptions.setComment("This service is intended to be used in framework tests.");
30  }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void setComment(std::string const &value)

◆ preBeginJob()

void edmtest::PathsAndConsumesOfModulesTestService::preBeginJob ( edm::PathsAndConsumesOfModulesBase const &  pathsAndConsumes,
edm::ProcessContext const &   
) const
inline

Definition at line 32 of file PathsAndConsumesOfModulesTestService.cc.

References edm::PathsAndConsumesOfModulesBase::allModules(), edmTracerLogToSimpleConfig::allModules, submitPVResolutionJobs::desc, newFWLiteAna::found, visualization-live-secondInstance_cfg::m, modulesConsumes_, and edm::PathsAndConsumesOfModulesBase::modulesWhoseProductsAreConsumedBy().

Referenced by PathsAndConsumesOfModulesTestService().

32  {
33  auto const& allModules = pathsAndConsumes.allModules();
34  for (auto const& moduleToCheck : modulesConsumes_) {
35  auto found =
36  std::find_if(allModules.begin(), allModules.end(), [&moduleToCheck](edm::ModuleDescription const* desc) {
37  return desc->moduleLabel() == moduleToCheck.first;
38  });
39  if (found == allModules.end()) {
40  cms::Exception ex("TestFailure");
41  ex << "Module " << moduleToCheck.first
42  << " not found in PathsAndConsumesOfModulesBase, that has the following modules:\n";
43  for (edm::ModuleDescription const* desc : allModules) {
44  if (desc) {
45  ex << " " << desc->moduleLabel() << "\n";
46  } else {
47  ex << " nullptr\n";
48  }
49  }
50  throw ex;
51  }
52 
53  std::set<std::string> tocheck(moduleToCheck.second.begin(), moduleToCheck.second.end());
54  for (edm::ModuleDescription const* desc : pathsAndConsumes.modulesWhoseProductsAreConsumedBy((*found)->id())) {
55  auto found = tocheck.find(desc->moduleLabel());
56  if (found == tocheck.end()) {
57  cms::Exception ex("TestFailure");
58  ex << "Module " << moduleToCheck.first << " consumes " << desc->moduleLabel()
59  << " that was not one of the expected modules:\n";
60  for (auto const& m : moduleToCheck.second) {
61  ex << " " << m << "\n";
62  }
63  throw ex;
64  }
65  tocheck.erase(found);
66  }
67  if (not tocheck.empty()) {
68  cms::Exception ex("TestFailure");
69  ex << "Module " << moduleToCheck.first << " was expected to consume the following modules, but it did not\n";
70  for (auto const& m : tocheck) {
71  ex << " " << m << "\n";
72  }
73  throw ex;
74  }
75  }
76  }
std::vector< std::pair< std::string, std::vector< std::string > > > modulesConsumes_

Member Data Documentation

◆ modulesConsumes_

std::vector<std::pair<std::string, std::vector<std::string> > > edmtest::PathsAndConsumesOfModulesTestService::modulesConsumes_
private

Definition at line 79 of file PathsAndConsumesOfModulesTestService.cc.

Referenced by preBeginJob().