Skip to content

Commit

Permalink
Move framework test modules away from legacy types
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr15Jones committed Apr 18, 2022
1 parent 9bac750 commit 1eebd97
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 49 deletions.
20 changes: 10 additions & 10 deletions FWCore/Framework/test/edproducer_productregistry_callback.cc
Expand Up @@ -16,7 +16,7 @@
#include "FWCore/Framework/interface/ConstProductRegistry.h"
#include "FWCore/Framework/interface/PreallocationConfiguration.h"

#include "FWCore/Framework/interface/EDProducer.h"
#include "FWCore/Framework/interface/global/EDProducer.h"
#include "FWCore/Framework/interface/ExceptionActions.h"
#include "DataFormats/Provenance/interface/ProductRegistry.h"
#include "DataFormats/Provenance/interface/ProcessConfiguration.h"
Expand Down Expand Up @@ -52,31 +52,31 @@ CPPUNIT_TEST_SUITE_REGISTRATION(testEDProducerProductRegistryCallback);
using namespace edm;

namespace {
class TestMod : public EDProducer {
class TestMod : public global::EDProducer<> {
public:
explicit TestMod(ParameterSet const& p);

void produce(Event& e, EventSetup const&);
void produce(StreamID, Event& e, EventSetup const&) const override;

void listen(BranchDescription const&);
};

TestMod::TestMod(ParameterSet const&) { produces<int>(); }

void TestMod::produce(Event&, EventSetup const&) {}
void TestMod::produce(StreamID, Event&, EventSetup const&) const {}

class ListenMod : public EDProducer {
class ListenMod : public global::EDProducer<> {
public:
explicit ListenMod(ParameterSet const&);
void produce(Event& e, EventSetup const&);
void produce(StreamID, Event& e, EventSetup const&) const override;
void listen(BranchDescription const&);
};

ListenMod::ListenMod(ParameterSet const&) {
callWhenNewProductsRegistered(
[this](BranchDescription const& branchDescription) { this->listen(branchDescription); });
}
void ListenMod::produce(Event&, EventSetup const&) {}
void ListenMod::produce(StreamID, Event&, EventSetup const&) const {}

void ListenMod::listen(BranchDescription const& iDesc) {
edm::TypeID intType(typeid(int));
Expand All @@ -87,18 +87,18 @@ namespace {
}
}

class ListenFloatMod : public EDProducer {
class ListenFloatMod : public global::EDProducer<> {
public:
explicit ListenFloatMod(ParameterSet const&);
void produce(Event& e, EventSetup const&);
void produce(StreamID, Event& e, EventSetup const&) const;
void listen(BranchDescription const&);
};

ListenFloatMod::ListenFloatMod(ParameterSet const&) {
callWhenNewProductsRegistered(
[this](BranchDescription const& branchDescription) { this->listen(branchDescription); });
}
void ListenFloatMod::produce(Event&, EventSetup const&) {}
void ListenFloatMod::produce(StreamID, Event&, EventSetup const&) const {}

void ListenFloatMod::listen(BranchDescription const& iDesc) {
edm::TypeID intType(typeid(int));
Expand Down
8 changes: 4 additions & 4 deletions FWCore/Framework/test/maker2_t.cppunit.cc
Expand Up @@ -6,7 +6,7 @@
#include "FWCore/Utilities/interface/GetPassID.h"
#include "FWCore/Version/interface/GetReleaseVersion.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDProducer.h"
#include "FWCore/Framework/interface/global/EDProducer.h"
#include "FWCore/Framework/interface/maker/WorkerT.h"
#include "FWCore/Framework/interface/PreallocationConfiguration.h"
#include "FWCore/Framework/interface/ExceptionActions.h"
Expand All @@ -20,16 +20,16 @@

using namespace edm;

class TestMod : public EDProducer {
class TestMod : public global::EDProducer<> {
public:
explicit TestMod(ParameterSet const& p);

void produce(Event& e, EventSetup const&);
void produce(StreamID, Event& e, EventSetup const&) const override;
};

TestMod::TestMod(ParameterSet const&) { produces<int>(); }

void TestMod::produce(Event&, EventSetup const&) {}
void TestMod::produce(StreamID, Event&, EventSetup const&) const {}

// ----------------------------------------------
class testmaker2 : public CppUnit::TestFixture {
Expand Down
18 changes: 9 additions & 9 deletions FWCore/Framework/test/stubs/TestBeginEndJobAnalyzer.h
Expand Up @@ -19,23 +19,23 @@
//

// system include files
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
// user include files

// forward declarations
class TestBeginEndJobAnalyzer : public edm::EDAnalyzer {
class TestBeginEndJobAnalyzer : public edm::one::EDAnalyzer<edm::one::WatchRuns, edm::one::WatchLuminosityBlocks> {
public:
explicit TestBeginEndJobAnalyzer(const edm::ParameterSet&);
~TestBeginEndJobAnalyzer();

virtual void analyze(const edm::Event&, const edm::EventSetup&) override;
void analyze(const edm::Event&, const edm::EventSetup&) override;

virtual void beginJob() override;
virtual void endJob() override;
virtual void beginRun(edm::Run const&, edm::EventSetup const&) override;
virtual void endRun(edm::Run const&, edm::EventSetup const&) override;
virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
void beginJob() override;
void endJob() override;
void beginRun(edm::Run const&, edm::EventSetup const&) override;
void endRun(edm::Run const&, edm::EventSetup const&) override;
void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;

struct Control {
bool beginJobCalled = false;
Expand Down
7 changes: 1 addition & 6 deletions FWCore/Framework/test/stubs/TestFailuresAnalyzer.cc
Expand Up @@ -55,11 +55,6 @@ TestFailuresAnalyzer::TestFailuresAnalyzer(const edm::ParameterSet& iConfig)
}
}

TestFailuresAnalyzer::~TestFailuresAnalyzer() {
// do anything here that needs to be done at desctruction time
// (e.g. close files, deallocate resources etc.)
}

//
// member functions
//
Expand All @@ -80,7 +75,7 @@ void TestFailuresAnalyzer::endJob() {
}
}

void TestFailuresAnalyzer::analyze(const edm::Event& e /* iEvent */, const edm::EventSetup& /* iSetup */) {
void TestFailuresAnalyzer::analyze(edm::StreamID, const edm::Event& e /* iEvent */, const edm::EventSetup& /* iSetup */) const {
if (whichFailure_ == kEvent) {
throw cms::Exception("Test") << " event";
}
Expand Down
15 changes: 7 additions & 8 deletions FWCore/Framework/test/stubs/TestFailuresAnalyzer.h
Expand Up @@ -19,24 +19,23 @@
//

// system include files
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/global/EDAnalyzer.h"
// user include files

// forward declarations
class TestFailuresAnalyzer : public edm::EDAnalyzer {
class TestFailuresAnalyzer : public edm::global::EDAnalyzer<> {
public:
explicit TestFailuresAnalyzer(const edm::ParameterSet&);
~TestFailuresAnalyzer();

virtual void analyze(const edm::Event&, const edm::EventSetup&);
void analyze(edm::StreamID, const edm::Event&, const edm::EventSetup&) const final;

virtual void beginJob();
virtual void endJob();
void beginJob() final;
void endJob() final;

private:
// ----------member data ---------------------------
int whichFailure_;
unsigned long long eventToThrow_;
const int whichFailure_;
const unsigned long long eventToThrow_;
};

#endif /* test_TestFailuresAnalyzer_h */
2 changes: 1 addition & 1 deletion FWCore/Integration/test/HierarchicalEDProducer.cc
Expand Up @@ -12,7 +12,7 @@ namespace edmtest {
HierarchicalEDProducer::~HierarchicalEDProducer() {}

// Functions that gets called by framework every event
void HierarchicalEDProducer::produce(edm::Event&, edm::EventSetup const&) {
void HierarchicalEDProducer::produce(edm::StreamID, edm::Event&, edm::EventSetup const&) const {
// nothing to do ... is just a dummy!
}
} // namespace edmtest
Expand Down
12 changes: 6 additions & 6 deletions FWCore/Integration/test/HierarchicalEDProducer.h
Expand Up @@ -9,21 +9,21 @@
************************************************************/

#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDProducer.h"
#include "FWCore/Framework/interface/global/EDProducer.h"
#include "FWCore/Integration/test/HierarchicalAlgorithms.h"

namespace edmtest {
class HierarchicalEDProducer : public edm::EDProducer {
class HierarchicalEDProducer : public edm::global::EDProducer<> {
public:
explicit HierarchicalEDProducer(edm::ParameterSet const& ps);

virtual ~HierarchicalEDProducer();
~HierarchicalEDProducer() override;

virtual void produce(edm::Event& e, edm::EventSetup const& c);
void produce(edm::StreamID, edm::Event& e, edm::EventSetup const& c) const override;

private:
double radius_;
alg_1 outer_alg_;
const double radius_;
const alg_1 outer_alg_;
};
} // namespace edmtest
#endif
2 changes: 1 addition & 1 deletion FWCore/Integration/test/ProdigalAnalyzer.cc
Expand Up @@ -9,7 +9,7 @@
namespace edmtest {
ProdigalAnalyzer::ProdigalAnalyzer(edm::ParameterSet const&) { consumes<Prodigal>(edm::InputTag{"maker"}); }

void ProdigalAnalyzer::analyze(edm::Event const& e, edm::EventSetup const&) {
void ProdigalAnalyzer::analyze(edm::StreamID, edm::Event const& e, edm::EventSetup const&) const {
edm::Handle<Prodigal> h;
assert(e.getByLabel("maker", h));
assert(h.provenance()->productProvenance()->parentage().parents().empty());
Expand Down
7 changes: 3 additions & 4 deletions FWCore/Integration/test/ProdigalAnalyzer.h
Expand Up @@ -2,15 +2,14 @@
#define Integration_ProdigalAnalyzer_h

#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/global/EDAnalyzer.h"

namespace edmtest {

class ProdigalAnalyzer : public edm::EDAnalyzer {
class ProdigalAnalyzer : public edm::global::EDAnalyzer<> {
public:
explicit ProdigalAnalyzer(edm::ParameterSet const& pset);
virtual ~ProdigalAnalyzer() {}
virtual void analyze(edm::Event const& e, edm::EventSetup const& c);
void analyze(edm::StreamID, edm::Event const& e, edm::EventSetup const& c) const final;
};

} // namespace edmtest
Expand Down

0 comments on commit 1eebd97

Please sign in to comment.