@@ -58,6 +58,10 @@ namespace testParameterSetDescription {
5858 static void fillPSetDescription (edm::ParameterSetDescription& iPS) { iPS.add <double >(" aDouble" , 0.5 ); }
5959 };
6060
61+ struct CTestPlugin : public TestPluginBase {
62+ static void fillPSetDescription (edm::ParameterSetDescription& iPS) { iPS.addUntracked <int >(" anInt" , 42 ); }
63+ };
64+
6165 using TestPluginFactory = edmplugin::PluginFactory<testParameterSetDescription::TestPluginBase*()>;
6266
6367} // namespace testParameterSetDescription
@@ -67,6 +71,9 @@ using TestPluginFactory = testParameterSetDescription::TestPluginFactory;
6771using testParameterSetDescription::testDesc;
6872
6973TEST_CASE (" test ParameterSetDescription" , " [ParameterSetDescription]" ) {
74+ static std::once_flag flag;
75+ std::call_once (flag, []() { edmplugin::PluginManager::configure (edmplugin::standard::config ()); });
76+
7077 SECTION (" testWildcards" ) {
7178 using Catch::Matchers::Equals;
7279 {
@@ -1160,9 +1167,7 @@ TEST_CASE("test ParameterSetDescription", "[ParameterSetDescription]") {
11601167 // ---------------------------------------------------------------------------------
11611168
11621169 SECTION (" testPlugin" ) {
1163- static std::once_flag flag;
1164- std::call_once (flag, []() { edmplugin::PluginManager::configure (edmplugin::standard::config ()); });
1165- {
1170+ SECTION (" Plugin A" ) {
11661171 edm::ParameterSetDescription desc;
11671172 desc.addNode (edm::PluginDescription<TestPluginFactory>(" type" , true ));
11681173
@@ -1173,7 +1178,7 @@ TEST_CASE("test ParameterSetDescription", "[ParameterSetDescription]") {
11731178 desc.validate (pset1);
11741179 }
11751180
1176- {
1181+ SECTION ( " Plugin B " ) {
11771182 edm::ParameterSetDescription desc;
11781183 desc.addNode (edm::PluginDescription<TestPluginFactory>(" type" , true ));
11791184
@@ -1184,8 +1189,18 @@ TEST_CASE("test ParameterSetDescription", "[ParameterSetDescription]") {
11841189 desc.validate (pset1);
11851190 }
11861191
1187- {
1188- // add defaults
1192+ SECTION (" Plugin C" ) {
1193+ edm::ParameterSetDescription desc;
1194+ desc.addNode (edm::PluginDescription<TestPluginFactory>(" type" , true ));
1195+
1196+ edm::ParameterSet pset1;
1197+ pset1.addParameter <std::string>(" type" , " CTestPlugin" );
1198+ pset1.addUntrackedParameter <int >(" anInt" , 4 );
1199+
1200+ desc.validate (pset1);
1201+ }
1202+
1203+ SECTION (" Let validation to inject parameter" ) {
11891204 edm::ParameterSetDescription desc;
11901205 desc.addNode (edm::PluginDescription<TestPluginFactory>(" type" , true ));
11911206
@@ -1195,8 +1210,17 @@ TEST_CASE("test ParameterSetDescription", "[ParameterSetDescription]") {
11951210 CHECK (pset1.getParameter <int >(" anInt" ) == 5 );
11961211 }
11971212
1198- {
1199- // add defaults
1213+ SECTION (" Let validation to inject untracked parameter" ) {
1214+ edm::ParameterSetDescription desc;
1215+ desc.addNode (edm::PluginDescription<TestPluginFactory>(" type" , true ));
1216+
1217+ edm::ParameterSet pset1;
1218+ pset1.addParameter <std::string>(" type" , " CTestPlugin" );
1219+ desc.validate (pset1);
1220+ CHECK (pset1.getUntrackedParameter <int >(" anInt" ) == 42 );
1221+ }
1222+
1223+ SECTION (" Let validation to inject also 'type'" ) {
12001224 edm::ParameterSetDescription desc;
12011225 desc.addNode (edm::PluginDescription<TestPluginFactory>(" type" , " ATestPlugin" , true ));
12021226
@@ -1206,8 +1230,7 @@ TEST_CASE("test ParameterSetDescription", "[ParameterSetDescription]") {
12061230 CHECK (pset1.getParameter <std::string>(" type" ) == " ATestPlugin" );
12071231 }
12081232
1209- {
1210- // an additional parameter
1233+ SECTION (" Add additional parameter" ) {
12111234 edm::ParameterSetDescription desc;
12121235 desc.addNode (edm::PluginDescription<TestPluginFactory>(" type" , true ));
12131236
@@ -1237,8 +1260,7 @@ TEST_CASE("test ParameterSetDescription", "[ParameterSetDescription]") {
12371260 top.validate (psetTop);
12381261 }
12391262
1240- {
1241- // missing type
1263+ SECTION (" Missing 'type'" ) {
12421264 edm::ParameterSetDescription desc;
12431265 desc.addNode (edm::PluginDescription<TestPluginFactory>(" type" , true ));
12441266
@@ -1248,8 +1270,7 @@ TEST_CASE("test ParameterSetDescription", "[ParameterSetDescription]") {
12481270 REQUIRE_THROWS_AS (desc.validate (pset1), edm::Exception);
12491271 }
12501272
1251- {
1252- // a non-existent type
1273+ SECTION (" Non-existent type" ) {
12531274 edm::ParameterSetDescription desc;
12541275 desc.addNode (edm::PluginDescription<TestPluginFactory>(" type" , true ));
12551276
@@ -1258,6 +1279,28 @@ TEST_CASE("test ParameterSetDescription", "[ParameterSetDescription]") {
12581279
12591280 REQUIRE_THROWS_AS (desc.validate (pset1), cms::Exception);
12601281 }
1282+
1283+ SECTION (" Untracked 'type'" ) {
1284+ edm::ParameterSetDescription desc;
1285+ desc.addNode (edm::PluginDescription<TestPluginFactory>(" type" , false ));
1286+
1287+ edm::ParameterSet pset1;
1288+ pset1.addUntrackedParameter <std::string>(" type" , " ATestPlugin" );
1289+ pset1.addParameter <int >(" anInt" , 3 );
1290+
1291+ desc.validate (pset1);
1292+ }
1293+
1294+ SECTION (" Untracked 'type' and other parameters" ) {
1295+ edm::ParameterSetDescription desc;
1296+ desc.addNode (edm::PluginDescription<TestPluginFactory>(" type" , false ));
1297+
1298+ edm::ParameterSet pset1;
1299+ pset1.addUntrackedParameter <std::string>(" type" , " CTestPlugin" );
1300+ pset1.addUntrackedParameter <int >(" anInt" , 3 );
1301+
1302+ desc.validate (pset1);
1303+ }
12611304 }
12621305
12631306 SECTION (" VPSet with defaults" ) {
@@ -1358,6 +1401,187 @@ TEST_CASE("test ParameterSetDescription", "[ParameterSetDescription]") {
13581401
13591402 psetDesc.addVPSet (" vp" , templte, defaults);
13601403 }
1404+
1405+ SECTION (" VPSet with plugin" ) {
1406+ SECTION (" Tracked 'type' and parameters" ) {
1407+ edm::ParameterSetDescription pluginDesc;
1408+ pluginDesc.addNode (edm::PluginDescription<TestPluginFactory>(" type" , true ));
1409+ std::vector<edm::ParameterSet> defaults;
1410+ edm::ParameterSetDescription desc;
1411+ desc.addVPSet (" plugins" , pluginDesc, defaults);
1412+
1413+ SECTION (" Empty" ) {
1414+ edm::ParameterSet pset;
1415+ desc.validate (pset);
1416+ CHECK (pset.getParameter <std::vector<edm::ParameterSet>>(" plugins" ).empty ());
1417+ }
1418+
1419+ SECTION (" One plugin" ) {
1420+ edm::ParameterSet pset;
1421+ {
1422+ edm::ParameterSet pluginPSet;
1423+ pluginPSet.addParameter <std::string>(" type" , " ATestPlugin" );
1424+ pset.addParameter <std::vector<edm::ParameterSet>>(" plugins" , {pluginPSet});
1425+ }
1426+ desc.validate (pset);
1427+
1428+ auto const & vpset = pset.getParameter <std::vector<edm::ParameterSet>>(" plugins" );
1429+ REQUIRE (vpset.size () == 1 );
1430+ CHECK (vpset[0 ].getParameter <int >(" anInt" ) == 5 );
1431+ }
1432+ }
1433+
1434+ SECTION (" Untracked 'type' with tracked parameters" ) {
1435+ edm::ParameterSetDescription pluginDesc;
1436+ pluginDesc.addNode (edm::PluginDescription<TestPluginFactory>(" type" , false ));
1437+ std::vector<edm::ParameterSet> defaults;
1438+ edm::ParameterSetDescription desc;
1439+ desc.addVPSet (" plugins" , pluginDesc, defaults);
1440+
1441+ edm::ParameterSet pset;
1442+ {
1443+ edm::ParameterSet pluginPSet;
1444+ pluginPSet.addUntrackedParameter <std::string>(" type" , " ATestPlugin" );
1445+ pset.addParameter <std::vector<edm::ParameterSet>>(" plugins" , {pluginPSet});
1446+ }
1447+ desc.validate (pset);
1448+
1449+ auto const & vpset = pset.getParameter <std::vector<edm::ParameterSet>>(" plugins" );
1450+ REQUIRE (vpset.size () == 1 );
1451+ CHECK (vpset[0 ].getParameter <int >(" anInt" ) == 5 );
1452+ }
1453+
1454+ SECTION (" Tracked 'type' with untracked parameters" ) {
1455+ edm::ParameterSetDescription pluginDesc;
1456+ pluginDesc.addNode (edm::PluginDescription<TestPluginFactory>(" type" , true ));
1457+ std::vector<edm::ParameterSet> defaults;
1458+ edm::ParameterSetDescription desc;
1459+ desc.addVPSet (" plugins" , pluginDesc, defaults);
1460+
1461+ edm::ParameterSet pset;
1462+ {
1463+ edm::ParameterSet pluginPSet;
1464+ pluginPSet.addParameter <std::string>(" type" , " CTestPlugin" );
1465+ pset.addParameter <std::vector<edm::ParameterSet>>(" plugins" , {pluginPSet});
1466+ }
1467+ desc.validate (pset);
1468+
1469+ auto const & vpset = pset.getParameter <std::vector<edm::ParameterSet>>(" plugins" );
1470+ REQUIRE (vpset.size () == 1 );
1471+ CHECK (vpset[0 ].getUntrackedParameter <int >(" anInt" ) == 42 );
1472+ }
1473+
1474+ SECTION (" Untracked 'type' with untracked parameters" ) {
1475+ edm::ParameterSetDescription pluginDesc;
1476+ pluginDesc.addNode (edm::PluginDescription<TestPluginFactory>(" type" , false ));
1477+ std::vector<edm::ParameterSet> defaults;
1478+ edm::ParameterSetDescription desc;
1479+ desc.addVPSet (" plugins" , pluginDesc, defaults);
1480+
1481+ edm::ParameterSet pset;
1482+ {
1483+ edm::ParameterSet pluginPSet;
1484+ pluginPSet.addUntrackedParameter <std::string>(" type" , " CTestPlugin" );
1485+ pset.addParameter <std::vector<edm::ParameterSet>>(" plugins" , {pluginPSet});
1486+ }
1487+ desc.validate (pset);
1488+
1489+ auto const & vpset = pset.getParameter <std::vector<edm::ParameterSet>>(" plugins" );
1490+ REQUIRE (vpset.size () == 1 );
1491+ CHECK (vpset[0 ].getUntrackedParameter <int >(" anInt" ) == 42 );
1492+ }
1493+ }
1494+
1495+ SECTION (" Untracked VPSet with plugin" ) {
1496+ SECTION (" Tracked 'type' and parameters" ) {
1497+ edm::ParameterSetDescription pluginDesc;
1498+ pluginDesc.addNode (edm::PluginDescription<TestPluginFactory>(" type" , true ));
1499+ std::vector<edm::ParameterSet> defaults;
1500+ edm::ParameterSetDescription desc;
1501+ desc.addVPSetUntracked (" plugins" , pluginDesc, defaults);
1502+
1503+ SECTION (" Empty" ) {
1504+ edm::ParameterSet pset;
1505+ desc.validate (pset);
1506+ CHECK (pset.getUntrackedParameter <std::vector<edm::ParameterSet>>(" plugins" ).empty ());
1507+ }
1508+
1509+ SECTION (" One plugin" ) {
1510+ edm::ParameterSet pset;
1511+ {
1512+ edm::ParameterSet pluginPSet;
1513+ pluginPSet.addParameter <std::string>(" type" , " ATestPlugin" );
1514+ pset.addUntrackedParameter <std::vector<edm::ParameterSet>>(" plugins" , {pluginPSet});
1515+ }
1516+ desc.validate (pset);
1517+
1518+ auto const & vpset = pset.getUntrackedParameter <std::vector<edm::ParameterSet>>(" plugins" );
1519+ REQUIRE (vpset.size () == 1 );
1520+ CHECK (vpset[0 ].getParameter <int >(" anInt" ) == 5 );
1521+ }
1522+ }
1523+
1524+ SECTION (" Untracked 'type' with tracked parameters" ) {
1525+ edm::ParameterSetDescription pluginDesc;
1526+ pluginDesc.addNode (edm::PluginDescription<TestPluginFactory>(" type" , false ));
1527+ std::vector<edm::ParameterSet> defaults;
1528+ edm::ParameterSetDescription desc;
1529+ desc.addVPSetUntracked (" plugins" , pluginDesc, defaults);
1530+
1531+ edm::ParameterSet pset;
1532+ {
1533+ edm::ParameterSet pluginPSet;
1534+ pluginPSet.addUntrackedParameter <std::string>(" type" , " ATestPlugin" );
1535+ pset.addUntrackedParameter <std::vector<edm::ParameterSet>>(" plugins" , {pluginPSet});
1536+ }
1537+ desc.validate (pset);
1538+
1539+ auto const & vpset = pset.getUntrackedParameter <std::vector<edm::ParameterSet>>(" plugins" );
1540+ REQUIRE (vpset.size () == 1 );
1541+ CHECK (vpset[0 ].getParameter <int >(" anInt" ) == 5 );
1542+ }
1543+
1544+ SECTION (" Tracked 'type' with untracked parameters" ) {
1545+ edm::ParameterSetDescription pluginDesc;
1546+ pluginDesc.addNode (edm::PluginDescription<TestPluginFactory>(" type" , true ));
1547+ std::vector<edm::ParameterSet> defaults;
1548+ edm::ParameterSetDescription desc;
1549+ desc.addVPSetUntracked (" plugins" , pluginDesc, defaults);
1550+
1551+ edm::ParameterSet pset;
1552+ {
1553+ edm::ParameterSet pluginPSet;
1554+ pluginPSet.addParameter <std::string>(" type" , " CTestPlugin" );
1555+ pset.addUntrackedParameter <std::vector<edm::ParameterSet>>(" plugins" , {pluginPSet});
1556+ }
1557+ desc.validate (pset);
1558+
1559+ auto const & vpset = pset.getUntrackedParameter <std::vector<edm::ParameterSet>>(" plugins" );
1560+ REQUIRE (vpset.size () == 1 );
1561+ CHECK (vpset[0 ].getUntrackedParameter <int >(" anInt" ) == 42 );
1562+ }
1563+
1564+ SECTION (" Untracked 'type' with untracked parameters" ) {
1565+ edm::ParameterSetDescription pluginDesc;
1566+ pluginDesc.addNode (edm::PluginDescription<TestPluginFactory>(" type" , false ));
1567+ std::vector<edm::ParameterSet> defaults;
1568+ edm::ParameterSetDescription desc;
1569+ desc.addVPSetUntracked (" plugins" , pluginDesc, defaults);
1570+
1571+ edm::ParameterSet pset;
1572+ {
1573+ edm::ParameterSet pluginPSet;
1574+ pluginPSet.addUntrackedParameter <std::string>(" type" , " CTestPlugin" );
1575+ pset.addUntrackedParameter <std::vector<edm::ParameterSet>>(" plugins" , {pluginPSet});
1576+ }
1577+ desc.validate (pset);
1578+
1579+ auto const & vpset = pset.getUntrackedParameter <std::vector<edm::ParameterSet>>(" plugins" );
1580+ REQUIRE (vpset.size () == 1 );
1581+ CHECK (vpset[0 ].getUntrackedParameter <int >(" anInt" ) == 42 );
1582+ }
1583+ }
1584+
13611585 SECTION (" writeCfi full" ) {
13621586 edm::ParameterSet test;
13631587 test.addParameter (" vp" , defaults);
@@ -2101,3 +2325,4 @@ EDM_REGISTER_VALIDATED_PLUGINFACTORY(TestPluginFactory, "TestPluginFWCoreParamet
21012325
21022326DEFINE_EDM_VALIDATED_PLUGIN (TestPluginFactory, testParameterSetDescription::ATestPlugin, " ATestPlugin" );
21032327DEFINE_EDM_VALIDATED_PLUGIN (TestPluginFactory, testParameterSetDescription::BTestPlugin, " BTestPlugin" );
2328+ DEFINE_EDM_VALIDATED_PLUGIN (TestPluginFactory, testParameterSetDescription::CTestPlugin, " CTestPlugin" );
0 commit comments