|
| 1 | +#include "FWCore/TestProcessor/interface/TestProcessor.h" |
| 2 | +#include "FWCore/Utilities/interface/Exception.h" |
| 3 | +#include "FWCore/ServiceRegistry/interface/Service.h" |
| 4 | + |
| 5 | +#define CATCH_CONFIG_MAIN |
| 6 | +#include "catch.hpp" |
| 7 | + |
| 8 | +// Function to run the catch2 tests |
| 9 | +//___________________________________________________________________________________________ |
| 10 | +void runTestForAnalyzer(const std::string& baseConfig, const std::string& analyzerName) { |
| 11 | + edm::test::TestProcessor::Config config{baseConfig}; |
| 12 | + |
| 13 | + SECTION(analyzerName + " base configuration is OK") { REQUIRE_NOTHROW(edm::test::TestProcessor(config)); } |
| 14 | + |
| 15 | + SECTION("Run with no LuminosityBlocks") { |
| 16 | + edm::test::TestProcessor tester(config); |
| 17 | + REQUIRE_NOTHROW(tester.testRunWithNoLuminosityBlocks()); |
| 18 | + } |
| 19 | +} |
| 20 | + |
| 21 | +// Function to generate base configuration string |
| 22 | +//___________________________________________________________________________________________ |
| 23 | +std::string generateBaseConfig(const std::string& cfiName, const std::string& analyzerName) { |
| 24 | + // Define a raw string literal |
| 25 | + constexpr const char* rawString = R"_(from FWCore.TestProcessor.TestProcess import * |
| 26 | +from DQM.EcalCommon.{}_cfi import {} |
| 27 | +process = TestProcess() |
| 28 | +process.harvester = {} |
| 29 | +process.moduleToTest(process.harvester) |
| 30 | +process.add_(cms.Service('MessageLogger')) |
| 31 | +process.add_(cms.Service('JobReportService')) |
| 32 | +process.add_(cms.Service('DQMStore')) |
| 33 | + )_"; |
| 34 | + |
| 35 | + // Format the raw string literal using fmt::format |
| 36 | + return fmt::format(rawString, cfiName, analyzerName, analyzerName); |
| 37 | +} |
| 38 | + |
| 39 | +//___________________________________________________________________________________________ |
| 40 | +TEST_CASE("EcalMEFormatter tests", "[EcalMEFormatter]") { |
| 41 | + const std::string baseConfig = generateBaseConfig("EcalMEFormatter", "ecalMEFormatter"); |
| 42 | + runTestForAnalyzer(baseConfig, "EcalMEFormatter"); |
| 43 | +} |
0 commit comments