Skip to content

Commit 3c40068

Browse files
author
Kyungmin Park
committed
test EcalCommon with noLumiBlock
1 parent b95f2a5 commit 3c40068

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

DQM/EcalCommon/test/BuildFile.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<bin file="testEcalCommon.cc" name="testEcalCommon">
2+
<use name="FWCore/TestProcessor"/>
3+
<use name="catch2"/>
4+
</bin>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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

Comments
 (0)