1 #define BOOST_TEST_MODULE (GroupSelector_t) 2 #include "boost/test/unit_test.hpp" 23 template <
typename PROD>
45 std::vector<bool>& results)
47 for (
auto const&
p : descriptions) {
56 std::initializer_list<bool>
const&
expected)
60 params.
get<std::vector<std::string>>(parameterName, {
"keep *"}),
63 std::vector<bool> results;
69 apply_gs(gs, descriptions, results);
80 static GlobalSetup s_gs;
99 modAparams.
put(
"i", 2112);
100 modAparams.
put(
"s",
"hi");
102 auto b1 = makeBranchDescription<arttest::ProdTypeA<std::string>>(
104 auto b2 = makeBranchDescription<arttest::ProdTypeA<std::string>>(
110 modBparams.
put(
"d", 2.5);
112 auto b3 = makeBranchDescription<arttest::ProdTypeB<std::string>>(
117 auto b4 = makeBranchDescription<arttest::ProdTypeA<std::string>>(
119 auto b5 = makeBranchDescription<arttest::ProdTypeA<std::string>>(
123 auto b6 = makeBranchDescription<art::Ptr<std::string>>(
124 art::InRun,
"ptrmvWriter",
"PtrmvW",
"", modAparams);
129 descriptions.push_back(
132 descriptions.push_back(
135 descriptions.push_back(
138 descriptions.push_back(
141 descriptions.push_back(
144 descriptions.push_back(
151 struct ProductListAccessor {
157 BOOST_FIXTURE_TEST_SUITE(Tests, ProductListAccessor)
161 auto expected = {
true,
true,
true,
true,
true,
true};
163 doTest(noparams,
"default parameters", pTables,
expected);
168 auto expected = {
true,
false,
false,
false,
false,
true};
172 std::vector<std::string>
cmds;
173 cmds.push_back(keep_i2_rule);
174 keep_i2.
put(
"outputCommands", cmds);
176 doTest(keep_i2,
"keep i2 parameters", pTables,
expected);
181 auto expected = {
false,
true,
true,
true,
true,
false};
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);
191 doTest(drop_i2,
"drop i2 parameters", pTables,
expected);
196 auto expected = {
true,
true,
true,
true,
true,
true};
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);
206 doTest(drop_foo,
"drop_foo parameters", pTables,
expected);
211 auto expected = {
false,
false,
false,
true,
true,
false};
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);
221 doTest(drop_ProdTypeA,
"drop_ProdTypeA", pTables,
expected);
226 auto expected = {
false,
true,
false,
false,
false,
false};
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);
234 doTest(keep_i1prod,
"keep_i1prod", pTables,
expected);
239 auto expected = {
true,
true,
true,
true,
true,
true};
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);
251 doTest(indecisive,
"indecisive", pTables,
expected);
256 auto expected = {
false,
false,
true,
true,
true,
true};
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);
268 doTest(params,
"drop_modA_keep_user", pTables,
expected);
273 auto expected = {
true,
true,
false,
false,
true,
false};
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);
285 doTest(params,
"exercise wildcards1", pTables,
expected);
290 auto expected = {
true,
true,
true,
false,
true,
true};
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);
300 doTest(params,
"drop product by full spec.", pTables,
expected);
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(
314 "GroupSelectorTest"),
317 return e.categoryCode() == art::errors::Configuration;
323 auto expected = {
false,
false,
true,
true,
true,
true};
328 std::vector<std::string>
cmds;
329 cmds.push_back(rule1);
330 cmds.push_back(rule2);
331 params.
put(
"outputCommands", cmds);
333 doTest(params,
"drop product by full spec.", pTables,
expected);
338 auto expected = {
true,
true,
true,
true,
true,
false};
343 std::vector<std::string>
cmds;
344 cmds.push_back(rule1);
345 cmds.push_back(rule2);
346 params.
put(
"outputCommands", cmds);
348 doTest(params,
"drop product by full spec.", pTables,
expected);
353 auto expected = {
false,
false,
false,
false,
false,
true};
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);
363 doTest(params,
"drop product by full spec.", pTables,
expected);
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(
377 "GroupSelectorTest"),
380 return e.categoryCode() == art::errors::Configuration;
384 BOOST_AUTO_TEST_SUITE_END()
const std::string instance
bool selected(BranchDescription const &desc) const
std::vector< BranchDescription > ProductDescriptions
BOOST_TEST_REQUIRE(static_cast< bool >(inFile))
auto const & descriptions(BranchType const bt) const
T get(std::string const &key) const
std::string const & getReleaseVersion()
BOOST_AUTO_TEST_CASE(Test_default_parameters)
ParameterSetID id() const
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
std::map< ProductID, BranchDescription > ProductDescriptionsByID
void put(std::string const &key)