PathManager_t.cc
Go to the documentation of this file.
1 // vim: set sw=2 expandtab :
2 #define BOOST_TEST_MODULE (PathManager Test)
3 #include "boost/test/unit_test.hpp"
4 
11 #include "fhiclcpp/ParameterSet.h"
13 
14 #include <tuple>
15 #include <vector>
16 
17 using namespace std;
18 using namespace art;
19 
25 };
26 
27 BOOST_FIXTURE_TEST_SUITE(PathManager_t, PathManagerTestFixture)
28 
30 {
31  vector<tuple<string, errors::ErrorCodes, string>> test_sets;
32 
33  // Empty.
34  test_sets.emplace_back("", static_cast<errors::ErrorCodes>(0), "");
35 
36  // Correct.
37  test_sets.emplace_back("process_name: \"test\" "
38  "physics: { "
39  " producers: { "
40  " p: { module_type: PMTestProducer } "
41  " } "
42  " p1: [ p ] "
43  "}",
44  static_cast<errors::ErrorCodes>(0),
45  "");
46 
47  // Correct. Empty path-selection overrides despite presence of paths p1 and
48  // e1.
49  test_sets.emplace_back("process_name: \"test\" "
50  "physics: {"
51  " producers: {"
52  " p: { module_type: PMTestProducer }"
53  " }"
54  " analyzers: {"
55  " a: { module_type: DummyAnalyzer }"
56  " }"
57  " p1: [p]"
58  " e1: [a]"
59  " trigger_paths: []"
60  " end_paths: []"
61  "}",
62  static_cast<errors::ErrorCodes>(0),
63  "");
64 
65  // Module type mismatch.
66  test_sets.emplace_back("process_name: \"test\" "
67  "physics: { "
68  " producers: { "
69  " p: { module_type: PMTestFilter } "
70  " } "
71  " p1: [ p ] "
72  "}",
74  "---- Configuration BEGIN\n"
75  " The following were encountered while processing "
76  "the module configurations:\n"
77  " ERROR: Module with label p of type PMTestFilter "
78  "is configured as a producer but defined in code as a "
79  "filter.\n"
80  "---- Configuration END\n");
81 
82  for (auto const& [config_string, error_code, error_msg] : test_sets) {
83  auto raw_config = fhicl::parse_document(config_string);
84  auto const enabled_modules =
85  detail::prune_config_if_enabled(false, true, raw_config);
86  try {
87  auto const ps = fhicl::ParameterSet::make(raw_config);
89  ps, preg, productsToProduce, atable, areg, enabled_modules);
90  assert(error_code == 0);
91  }
92  catch (Exception const& e) {
93  if ((e.categoryCode() != error_code) || (e.what() != error_msg)) {
94  throw;
95  }
96  }
97  }
98 }
99 
100 BOOST_AUTO_TEST_SUITE_END()
static ParameterSet make(intermediate_table const &tbl)
Definition: ParameterSet.cc:68
STL namespace.
std::vector< BranchDescription > ProductDescriptions
ActivityRegistry areg
EnabledModules prune_config_if_enabled(bool prune_config, bool report_enabled, fhicl::intermediate_table &config)
const double e
static constexpr double ps
Definition: Units.h:99
BOOST_AUTO_TEST_CASE(Construct)
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
ProductDescriptions productsToProduce
intermediate_table parse_document(std::string const &filename, cet::filepath_maker &maker)
Definition: parse.cc:720
UpdateOutputCallbacks preg