Macros | Functions
GroupSelector_t.cc File Reference
#include "boost/test/unit_test.hpp"
#include "art/test/Framework/Core/GroupSelector_t.h"
#include "art/Framework/Core/GroupSelector.h"
#include "art/Framework/Core/GroupSelectorRules.h"
#include "art/Version/GetReleaseVersion.h"
#include "canvas/Persistency/Common/Ptr.h"
#include "canvas/Persistency/Common/traits.h"
#include "canvas/Persistency/Provenance/BranchDescription.h"
#include "canvas/Persistency/Provenance/ProcessConfiguration.h"
#include "canvas/Persistency/Provenance/ProductTables.h"
#include "canvas/Persistency/Provenance/TypeLabel.h"
#include "canvas/Utilities/Exception.h"
#include "fhiclcpp/ParameterSet.h"
#include <string>
#include <vector>

Go to the source code of this file.

Macros

#define BOOST_TEST_MODULE   (GroupSelector_t)
 

Functions

 BOOST_AUTO_TEST_CASE (Test_default_parameters)
 
 BOOST_AUTO_TEST_CASE (Keep_all_branches_with_instance_name_i2)
 
 BOOST_AUTO_TEST_CASE (Drop_all_branches_with_instance_name_i2)
 
 BOOST_AUTO_TEST_CASE (Drop_all_branches_with_product_type_foo)
 
 BOOST_AUTO_TEST_CASE (Drop_all_branches_with_product_type_ProdTypeA)
 
 BOOST_AUTO_TEST_CASE (Keep_only_production_branches_with_instance_name_i1)
 
 BOOST_AUTO_TEST_CASE (Keep_drop_keep)
 
 BOOST_AUTO_TEST_CASE (Keep_all_drop_from_modA_keep_USER)
 
 BOOST_AUTO_TEST_CASE (Exercise_wildcards)
 
 BOOST_AUTO_TEST_CASE (Drop_by_full_spec)
 
 BOOST_AUTO_TEST_CASE (Illegal_spec)
 
 BOOST_AUTO_TEST_CASE (Drop_by_type_event)
 
 BOOST_AUTO_TEST_CASE (Drop_by_type_results)
 
 BOOST_AUTO_TEST_CASE (Keep_by_type_results)
 
 BOOST_AUTO_TEST_CASE (Bad_type)
 

Macro Definition Documentation

#define BOOST_TEST_MODULE   (GroupSelector_t)

Definition at line 1 of file GroupSelector_t.cc.

Function Documentation

BOOST_AUTO_TEST_CASE ( Test_default_parameters  )

Definition at line 159 of file GroupSelector_t.cc.

160 {
161  auto expected = {true, true, true, true, true, true};
162  fhicl::ParameterSet noparams;
163  doTest(noparams, "default parameters", pTables, expected);
164 }
const char expected[]
Definition: Exception_t.cc:22
BOOST_AUTO_TEST_CASE ( Keep_all_branches_with_instance_name_i2  )

Definition at line 166 of file GroupSelector_t.cc.

167 {
168  auto expected = {true, false, false, false, false, true};
169 
170  fhicl::ParameterSet keep_i2;
171  std::string const keep_i2_rule = "keep *_*_i2_*";
172  std::vector<std::string> cmds;
173  cmds.push_back(keep_i2_rule);
174  keep_i2.put("outputCommands", cmds);
175 
176  doTest(keep_i2, "keep i2 parameters", pTables, expected);
177 }
const char expected[]
Definition: Exception_t.cc:22
std::string string
Definition: nybbler.cc:12
void put(std::string const &key)
BOOST_AUTO_TEST_CASE ( Drop_all_branches_with_instance_name_i2  )

Definition at line 179 of file GroupSelector_t.cc.

180 {
181  auto expected = {false, true, true, true, true, false};
182 
183  fhicl::ParameterSet drop_i2;
184  std::string const drop_i2_rule1 = "keep *";
185  std::string const drop_i2_rule2 = "drop *_*_i2_*";
186  std::vector<std::string> cmds;
187  cmds.push_back(drop_i2_rule1);
188  cmds.push_back(drop_i2_rule2);
189  drop_i2.put("outputCommands", cmds);
190 
191  doTest(drop_i2, "drop i2 parameters", pTables, expected);
192 }
const char expected[]
Definition: Exception_t.cc:22
std::string string
Definition: nybbler.cc:12
void put(std::string const &key)
BOOST_AUTO_TEST_CASE ( Drop_all_branches_with_product_type_foo  )

Definition at line 194 of file GroupSelector_t.cc.

195 {
196  auto expected = {true, true, true, true, true, true};
197 
198  fhicl::ParameterSet drop_foo;
199  std::string const drop_foo_rule1 = "keep *_*_*_*"; // same as "keep *"
200  std::string const drop_foo_rule2 = "drop foo_*_*_*";
201  std::vector<std::string> cmds;
202  cmds.push_back(drop_foo_rule1);
203  cmds.push_back(drop_foo_rule2);
204  drop_foo.put("outputCommands", cmds);
205 
206  doTest(drop_foo, "drop_foo parameters", pTables, expected);
207 }
const char expected[]
Definition: Exception_t.cc:22
std::string string
Definition: nybbler.cc:12
void put(std::string const &key)
BOOST_AUTO_TEST_CASE ( Drop_all_branches_with_product_type_ProdTypeA  )

Definition at line 209 of file GroupSelector_t.cc.

210 {
211  auto expected = {false, false, false, true, true, false};
212 
213  fhicl::ParameterSet drop_ProdTypeA;
214  std::string const drop_ProdTypeA_rule1 = "keep *";
215  std::string const drop_ProdTypeA_rule2 = "drop *ProdTypeA_*_*_*";
216  std::vector<std::string> cmds;
217  cmds.push_back(drop_ProdTypeA_rule1);
218  cmds.push_back(drop_ProdTypeA_rule2);
219  drop_ProdTypeA.put("outputCommands", cmds);
220 
221  doTest(drop_ProdTypeA, "drop_ProdTypeA", pTables, expected);
222 }
const char expected[]
Definition: Exception_t.cc:22
std::string string
Definition: nybbler.cc:12
void put(std::string const &key)
BOOST_AUTO_TEST_CASE ( Keep_only_production_branches_with_instance_name_i1  )

Definition at line 224 of file GroupSelector_t.cc.

225 {
226  auto expected = {false, true, false, false, false, false};
227 
228  fhicl::ParameterSet keep_i1prod;
229  std::string const keep_i1prod_rule = "keep *_*_i1_PROD";
230  std::vector<std::string> cmds;
231  cmds.push_back(keep_i1prod_rule);
232  keep_i1prod.put("outputCommands", cmds);
233 
234  doTest(keep_i1prod, "keep_i1prod", pTables, expected);
235 }
const char expected[]
Definition: Exception_t.cc:22
std::string string
Definition: nybbler.cc:12
void put(std::string const &key)
BOOST_AUTO_TEST_CASE ( Keep_drop_keep  )

Definition at line 237 of file GroupSelector_t.cc.

238 {
239  auto expected = {true, true, true, true, true, true};
240 
241  fhicl::ParameterSet indecisive;
242  std::string const indecisive_rule1 = "keep *";
243  std::string const indecisive_rule2 = "drop *";
244  std::string const indecisive_rule3 = "keep *";
245  std::vector<std::string> cmds;
246  cmds.push_back(indecisive_rule1);
247  cmds.push_back(indecisive_rule2);
248  cmds.push_back(indecisive_rule3);
249  indecisive.put("outputCommands", cmds);
250 
251  doTest(indecisive, "indecisive", pTables, expected);
252 }
const char expected[]
Definition: Exception_t.cc:22
std::string string
Definition: nybbler.cc:12
void put(std::string const &key)
BOOST_AUTO_TEST_CASE ( Keep_all_drop_from_modA_keep_USER  )

Definition at line 254 of file GroupSelector_t.cc.

255 {
256  auto expected = {false, false, true, true, true, true};
257 
259  std::string const rule1 = "keep *";
260  std::string const rule2 = "drop *_modA_*_*";
261  std::string const rule3 = "keep *_*_*_USER";
262  std::vector<std::string> cmds;
263  cmds.push_back(rule1);
264  cmds.push_back(rule2);
265  cmds.push_back(rule3);
266  params.put("outputCommands", cmds);
267 
268  doTest(params, "drop_modA_keep_user", pTables, expected);
269 }
const char expected[]
Definition: Exception_t.cc:22
std::string string
Definition: nybbler.cc:12
void put(std::string const &key)
BOOST_AUTO_TEST_CASE ( Exercise_wildcards  )

Definition at line 271 of file GroupSelector_t.cc.

272 {
273  auto expected = {true, true, false, false, true, false};
274 
276  std::string const rule1 = "drop *";
277  std::string const rule2 = "keep *Pr*A_m?dA_??_P?O*";
278  std::string const rule3 = "keep *?*?***??*????*?***_??***?__*?***T";
279  std::vector<std::string> cmds;
280  cmds.push_back(rule1);
281  cmds.push_back(rule2);
282  cmds.push_back(rule3);
283  params.put("outputCommands", cmds);
284 
285  doTest(params, "exercise wildcards1", pTables, expected);
286 }
const char expected[]
Definition: Exception_t.cc:22
std::string string
Definition: nybbler.cc:12
void put(std::string const &key)
BOOST_AUTO_TEST_CASE ( Drop_by_full_spec  )

Definition at line 288 of file GroupSelector_t.cc.

289 {
290  auto expected = {true, true, true, false, true, true};
291 
293  std::string const rule1 = "keep *";
294  std::string const rule2 = "drop Stringart::Ptr_ptrmvWriter__PtrmvW";
295  std::vector<std::string> cmds;
296  cmds.push_back(rule1);
297  cmds.push_back(rule2);
298  params.put("outputCommands", cmds);
299 
300  doTest(params, "drop product by full spec.", pTables, expected);
301 }
const char expected[]
Definition: Exception_t.cc:22
std::string string
Definition: nybbler.cc:12
void put(std::string const &key)
BOOST_AUTO_TEST_CASE ( Illegal_spec  )

Definition at line 303 of file GroupSelector_t.cc.

304 {
306  std::string const bad_rule = "beep *_*_i2_*";
307  std::vector<std::string> cmds;
308  cmds.push_back(bad_rule);
309  std::string const parameterName = "outputCommands";
310  bad.put(parameterName, cmds);
311  BOOST_REQUIRE_EXCEPTION(
312  art::GroupSelectorRules(bad.get<std::vector<std::string>>(parameterName),
313  parameterName,
314  "GroupSelectorTest"),
316  [](auto const& e) {
317  return e.categoryCode() == art::errors::Configuration;
318  });
319 }
std::string string
Definition: nybbler.cc:12
const double e
T get(std::string const &key) const
Definition: ParameterSet.h:271
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
unsigned int bad()
void put(std::string const &key)
BOOST_AUTO_TEST_CASE ( Drop_by_type_event  )

Definition at line 321 of file GroupSelector_t.cc.

322 {
323  auto expected = {false, false, true, true, true, true};
324 
326  std::string const rule1 = "keep *";
327  std::string const rule2 = "drop * InEvent";
328  std::vector<std::string> cmds;
329  cmds.push_back(rule1);
330  cmds.push_back(rule2);
331  params.put("outputCommands", cmds);
332 
333  doTest(params, "drop product by full spec.", pTables, expected);
334 }
const char expected[]
Definition: Exception_t.cc:22
std::string string
Definition: nybbler.cc:12
void put(std::string const &key)
BOOST_AUTO_TEST_CASE ( Drop_by_type_results  )

Definition at line 336 of file GroupSelector_t.cc.

337 {
338  auto expected = {true, true, true, true, true, false};
339 
341  std::string const rule1 = "keep *";
342  std::string const rule2 = "drop * InResults";
343  std::vector<std::string> cmds;
344  cmds.push_back(rule1);
345  cmds.push_back(rule2);
346  params.put("outputCommands", cmds);
347 
348  doTest(params, "drop product by full spec.", pTables, expected);
349 }
const char expected[]
Definition: Exception_t.cc:22
std::string string
Definition: nybbler.cc:12
void put(std::string const &key)
BOOST_AUTO_TEST_CASE ( Keep_by_type_results  )

Definition at line 351 of file GroupSelector_t.cc.

352 {
353  auto expected = {false, false, false, false, false, true};
354 
356  std::string const rule1 = "drop *";
357  std::string const rule2 = "keep *_*_*_* inResults";
358  std::vector<std::string> cmds;
359  cmds.push_back(rule1);
360  cmds.push_back(rule2);
361  params.put("outputCommands", cmds);
362 
363  doTest(params, "drop product by full spec.", pTables, expected);
364 }
const char expected[]
Definition: Exception_t.cc:22
std::string string
Definition: nybbler.cc:12
void put(std::string const &key)
BOOST_AUTO_TEST_CASE ( Bad_type  )

Definition at line 366 of file GroupSelector_t.cc.

367 {
369  std::string const bad_rule = "keep *_*_i2_* wibble";
370  std::vector<std::string> cmds;
371  cmds.push_back(bad_rule);
372  std::string const parameterName = "outputCommands";
373  bad.put(parameterName, cmds);
374  BOOST_REQUIRE_EXCEPTION(
375  art::GroupSelectorRules(bad.get<std::vector<std::string>>(parameterName),
376  parameterName,
377  "GroupSelectorTest"),
379  [](auto const& e) {
380  return e.categoryCode() == art::errors::Configuration;
381  });
382 }
std::string string
Definition: nybbler.cc:12
const double e
T get(std::string const &key) const
Definition: ParameterSet.h:271
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
unsigned int bad()
void put(std::string const &key)