LArSoft  v10_04_05
Liquid Argon Software toolkit - https://larsoft.org/
testing::GeometryTesterEnvironment< ConfigurationClass, ObjectSorter > Class Template Reference

Environment for a geometry test. More...

#include "geometry_unit_test_base.h"

Inheritance diagram for testing::GeometryTesterEnvironment< ConfigurationClass, ObjectSorter >:
testing::TesterEnvironment< ConfigurationClass > testing::BasicTesterEnvironment< ConfigurationClass >

Public Types

using Configuration_t = ConfigurationClass
 

Public Member Functions

 GeometryTesterEnvironment (bool bSetup=true)
 Constructor: sets everything up and declares the test started. More...
 
geo::GeometryCore const * Geometry () const noexcept
 
virtual ~GeometryTesterEnvironment ()
 Destructor: closing remarks. More...
 
template<typename Prov , typename... Args>
Prov * SetupProvider (Args &&...args)
 Sets a service provider up by calling its testing::setupProvider() More...
 
template<typename Prov , typename... Args>
Prov * SetupProviderFromService (std::string name, Args &&...args)
 Sets a service provider up by calling its testing::setupProvider() More...
 
template<typename Prov >
Prov * AcquireProvider (std::unique_ptr< Prov > &&prov)
 Acquires a service provider. More...
 
template<typename Interface , typename Prov , typename... Args>
Prov * SetupProviderFor (Args &&...args)
 Sets a provider up, recording it as implementation of Interface. More...
 
template<typename Interface , typename Prov , typename... Args>
Prov * SetupProviderFromServiceFor (std::string name, Args &&...args)
 Sets a provider up, recording it as implementation of Interface. More...
 
template<typename Interface , typename Prov >
Prov * AcquireProviderFor (std::unique_ptr< Prov > &&prov)
 Acquires a service provider implementing an interface. More...
 
template<typename Prov >
Prov * SimpleProviderSetup ()
 Oversimplified provider setup. More...
 
template<typename Prov >
void DropProvider ()
 Removes and destroys the specified provider. More...
 
template<typename Prov >
Prov const * Provider () const
 Return the specified provider (throws if not available) More...
 
template<typename... Provs>
void FillProviderPack (lar::ProviderPack< Provs... > &pack) const
 Fills the specified provider pack with providers. More...
 
template<typename Prov >
Prov::providers_type ProviderPackFor () const
 Returns a provider pack for the specified provider. More...
 
 GeometryTesterEnvironment (ConfigurationClass const &cfg_obj, bool bSetup=true)
 Setup from a configuration. More...
 
 GeometryTesterEnvironment (ConfigurationClass &&cfg_obj, bool bSetup=true)
 Setup from a configuration. More...
 
Configuration retrieval
fhicl::ParameterSet const & Parameters () const
 Returns the full configuration. More...
 
fhicl::ParameterSet ServiceParameters (std::string service_name) const
 Returns the configuration of the specified service. More...
 
fhicl::ParameterSet TesterParameters (std::string test_name) const
 Returns the configuration of the specified test. More...
 
fhicl::ParameterSet TesterParameters () const
 Returns the configuration of the main test (undefined if no main test) More...
 

Static Public Member Functions

static fhicl::ParameterSet CompileParameterSet (std::string cfg)
 Compiles a parameter set from a string. More...
 

Protected Member Functions

void Setup ()
 The complete initialization, ran at construction by default. More...
 
virtual std::unique_ptr< geo::GeometryCoreCreateNewGeometry () const
 Creates a new geometry. More...
 
Configuration_t const & Config () const
 Returns a read-only version of the configuration. More...
 
virtual void Configure ()
 Reads and translates the configuration. More...
 
virtual fhicl::ParameterSet DefaultParameters () const
 Creates a full configuration for the test. More...
 
virtual void SetupMessageFacility (fhicl::ParameterSet const &pset, std::string appl_name="") const
 Sets up the message facility. More...
 
virtual void SetupMessageFacility () const
 Sets up the message facility. More...
 

Static Protected Member Functions

static fhicl::ParameterSet ParseParameters (std::string config_path)
 Fills the test configuration from file or from default. More...
 

Protected Attributes

ProviderList providers
 list of available providers More...
 

Private Types

using TesterEnvironment_t = TesterEnvironment< ConfigurationClass >
 

Private Attributes

ConfigurationClass config
 instance of the configurer More...
 

Detailed Description

template<typename ConfigurationClass, typename ObjectSorter>
class testing::GeometryTesterEnvironment< ConfigurationClass, ObjectSorter >

Environment for a geometry test.


Template Parameters
ConfigurationClassa class providing compile-time configuration

The test environment is set up on construction.

The environment provides:

This class or a derived one can be used as global fixture for unit tests that require the presence of geometry (in the form of geo::GeometryCore instance).

Unfortunately Boost does not give any control on the initialization of the object, so everything must be ready to go as hard coded. The ConfigurationClass class tries to alleviate that. That is another, small static class that GeometryTesterEnvironment uses to get its parameters.

The requirements for the ConfigurationClass are:

  • ChannelMapClass: concrete type of channel mapping algorithm class
  • std::string ApplicationName(): the application name
  • std::string ConfigurationPath(): path to the configuration file
  • std::string GeometryParameterSetPath(): FHiCL path to the configuration of the geometry; in art is "services.Geometry"
  • std::string TesterParameterSetPath(): FHiCL path to the configuration of the geometry
  • std::string DefaultGeometryConfiguration() returning a FHiCL string to be parsed to extract the default geometry configuration
  • std::string DefaultTesterConfiguration() returning a FHiCL string to be parsed to extract the default test configuration

Whether the configuration comes from a file or from the two provided defaults, it is always expected within the parameter set paths: the default configuration must also contain that path.

Note that there is no room for polymorphism here since the setup happens on construction. Some methods are declared virtual in order to allow to tweak some steps of the set up, but it's not trivial to create a derived class that works correctly: the derived class must declare a new default constructor, and that default constructor must call the protected constructor (GeometryTesterEnvironment<ConfigurationClass>(no_setup))

Definition at line 179 of file geometry_unit_test_base.h.

Member Typedef Documentation

template<typename ConfigurationClass >
using testing::BasicTesterEnvironment< ConfigurationClass >::Configuration_t = ConfigurationClass
inherited

Definition at line 561 of file unit_test_base.h.

template<typename ConfigurationClass , typename ObjectSorter >
using testing::GeometryTesterEnvironment< ConfigurationClass, ObjectSorter >::TesterEnvironment_t = TesterEnvironment<ConfigurationClass>
private

Definition at line 180 of file geometry_unit_test_base.h.

Constructor & Destructor Documentation

template<typename ConfigurationClass , typename ObjectSorter >
testing::GeometryTesterEnvironment< ConfigurationClass, ObjectSorter >::GeometryTesterEnvironment ( bool  bSetup = true)
inline

Constructor: sets everything up and declares the test started.

The configuration is from a default-constructed ConfigurationClass. This is suitable for use as Boost unit test fixture.

Definition at line 189 of file geometry_unit_test_base.h.

189  : TesterEnvironment_t(false)
190  {
191  if (bSetup) Setup();
192  }
TesterEnvironment< ConfigurationClass > TesterEnvironment_t
void Setup()
The complete initialization, ran at construction by default.
template<typename ConfigurationClass , typename ObjectSorter >
testing::GeometryTesterEnvironment< ConfigurationClass, ObjectSorter >::GeometryTesterEnvironment ( ConfigurationClass const &  cfg_obj,
bool  bSetup = true 
)
inline

Setup from a configuration.

Parameters
configureran instance of ConfigurationClass

The configuration is from the specified configurer class.

This constructor allows to use a non-default-constructed configuration. This can't be used (at best of my knowledge) when using this class as Boost unit test fixture.

In the r-value-reference constructor, the configurer is moved.

Definition at line 206 of file geometry_unit_test_base.h.

207  : TesterEnvironment_t(cfg_obj, false)
208  {
209  if (bSetup) Setup();
210  }
TesterEnvironment< ConfigurationClass > TesterEnvironment_t
void Setup()
The complete initialization, ran at construction by default.
template<typename ConfigurationClass , typename ObjectSorter >
testing::GeometryTesterEnvironment< ConfigurationClass, ObjectSorter >::GeometryTesterEnvironment ( ConfigurationClass &&  cfg_obj,
bool  bSetup = true 
)
inline

Setup from a configuration.

Parameters
configureran instance of ConfigurationClass

The configuration is from the specified configurer class.

This constructor allows to use a non-default-constructed configuration. This can't be used (at best of my knowledge) when using this class as Boost unit test fixture.

In the r-value-reference constructor, the configurer is moved.

Definition at line 211 of file geometry_unit_test_base.h.

212  : TesterEnvironment_t(std::move(cfg_obj), false)
213  {
214  if (bSetup) Setup();
215  }
TesterEnvironment< ConfigurationClass > TesterEnvironment_t
void Setup()
The complete initialization, ran at construction by default.
template<typename ConfigurationClass , typename ObjectSorter >
testing::GeometryTesterEnvironment< ConfigurationClass, ObjectSorter >::~GeometryTesterEnvironment ( )
virtual

Destructor: closing remarks.

Definition at line 251 of file geometry_unit_test_base.h.

252  {
253  mf::LogInfo("Test") << config.ApplicationName() << " completed.";
254  }
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
ConfigurationClass config
instance of the configurer

Member Function Documentation

template<typename ConfigurationClass >
template<typename Prov >
Prov* testing::TesterEnvironment< ConfigurationClass >::AcquireProvider ( std::unique_ptr< Prov > &&  prov)
inlineinherited

Acquires a service provider.

Template Parameters
Provtype of provider
Parameters
provthe provider to be acquired
Returns
a pointer to the provider
See also
SetupProvider()
Exceptions
runtime_errorif the provider already exists

This method registers and takes ownership of the specified provider. It is similar to SetupProvider() except that user is in charge of the preliminary creation and setup of the provider.

Definition at line 813 of file unit_test_base.h.

814  {
815  if (!providers.acquire(std::move(prov))) throw std::runtime_error("Provider already exists!");
816  return providers.getPointer<Prov>();
817  }
T const * getPointer(std::string label="") const
Retrieve the object of type T stored with the specified label.
Definition: ProviderList.h:358
bool acquire(std::unique_ptr< T > &&obj_ptr, std::string label="")
Registers and gets ownership of the specified object.
Definition: ProviderList.h:266
ProviderList providers
list of available providers
template<typename ConfigurationClass >
template<typename Interface , typename Prov >
Prov* testing::TesterEnvironment< ConfigurationClass >::AcquireProviderFor ( std::unique_ptr< Prov > &&  prov)
inlineinherited

Acquires a service provider implementing an interface.

Template Parameters
Provtype of provider
Interfacetype provider alias
Parameters
provthe provider to be acquired
Returns
a pointer to the provider
See also
SetupProviderFor(), AcquireProvider()

This method registers and takes ownership of the specified provider, like AcquireProvider() does. It also registers the provider as an implementation of Interface class, as SetupProviderFor does. It is similar to SetupProvider() except that user is in charge of the preliminar creation and setup of the provider.

Definition at line 885 of file unit_test_base.h.

886  {
887  auto prov_ptr = prov.get();
888  providers.acquire(std::move(prov));
889  providers.set_alias<Prov, Interface>();
890  return prov_ptr;
891  }
bool acquire(std::unique_ptr< T > &&obj_ptr, std::string label="")
Registers and gets ownership of the specified object.
Definition: ProviderList.h:266
ProviderList providers
list of available providers
bool set_alias(std::string alias_label="", std::string prov_label="")
Sets the Alias type as an alias of the Prov provider (with labels)
Definition: ProviderList.h:306
template<typename ConfigurationClass >
fhicl::ParameterSet testing::BasicTesterEnvironment< ConfigurationClass >::CompileParameterSet ( std::string  cfg)
staticinherited

Compiles a parameter set from a string.


Returns
a parameters set with the complete configuration

Definition at line 1035 of file unit_test_base.h.

References fhicl::ParameterSet::make().

1037  {
1038  fhicl::ParameterSet global_pset;
1039  global_pset = fhicl::ParameterSet::make(cfg);
1040  return global_pset;
1041  }
static ParameterSet make(intermediate_table const &tbl)
Definition: ParameterSet.cc:68
template<typename ConfigurationClass >
Configuration_t const& testing::BasicTesterEnvironment< ConfigurationClass >::Config ( ) const
inlineprotectedinherited

Returns a read-only version of the configuration.

Definition at line 636 of file unit_test_base.h.

636 { return config; }
Configuration_t config
instance of the configurer
template<typename ConfigurationClass >
void testing::BasicTesterEnvironment< ConfigurationClass >::Configure ( )
protectedvirtualinherited

Reads and translates the configuration.

Fills the configuration.


The complete configuration (message facility and services) is read and saved, hence accessible by Parameters() method.

The configuration file path is taken by default from the first argument of the test. If that first argument is not present or empty, the default configuration path is received from the configurer. If the configuration path is still empty, a hard-coded configuration is used; otherwise, the FHiCL file specified in that path is parsed and used as full configuration.

Definition at line 1077 of file unit_test_base.h.

1078  {
1079  std::string config_path = config.ConfigurationPath();
1080  params = config_path.empty() ? DefaultParameters() : ParseParameters(config_path);
1081  }
fhicl::ParameterSet params
full configuration of the test
static fhicl::ParameterSet ParseParameters(std::string config_path)
Fills the test configuration from file or from default.
virtual fhicl::ParameterSet DefaultParameters() const
Creates a full configuration for the test.
Configuration_t config
instance of the configurer
template<typename ConfigurationClass , typename ObjectSorter >
std::unique_ptr< geo::GeometryCore > testing::GeometryTesterEnvironment< ConfigurationClass, ObjectSorter >::CreateNewGeometry ( ) const
protectedvirtual

Creates a new geometry.

Sets the geometry of the standard detector up.


This function sets up the geometry according to the provided information:

  • the configuration must contain enough information to locate the geometry description file
  • we trust that that geometry works well with the ChannelMapClass specified in ConfigurationClass

Definition at line 268 of file geometry_unit_test_base.h.

269  {
270  std::string ProviderParameterSetPath = this->Config().GeometryParameterSetPath();
271 
272  fhicl::ParameterSet ProviderConfig =
273  this->Parameters().template get<fhicl::ParameterSet>(ProviderParameterSetPath);
274 
275  return std::make_unique<geo::GeometryCore>(
276  ProviderConfig,
277  std::make_unique<geo::GeometryBuilderStandard>(
278  ProviderConfig.get<fhicl::ParameterSet>("Builder", {})),
279  createSorter<ObjectSorter>(ProviderConfig.get<fhicl::ParameterSet>("SortingParameters", {})));
280  }
fhicl::ParameterSet const & Parameters() const
Returns the full configuration.
Configuration_t const & Config() const
Returns a read-only version of the configuration.
template<typename ConfigurationClass >
virtual fhicl::ParameterSet testing::BasicTesterEnvironment< ConfigurationClass >::DefaultParameters ( ) const
inlineprotectedvirtualinherited

Creates a full configuration for the test.

Returns
a parameters set with the complete configuration

Definition at line 648 of file unit_test_base.h.

References lar::standalone::SetupMessageFacility().

649  {
650  return CompileParameterSet(config.DefaultConfiguration());
651  }
Configuration_t config
instance of the configurer
static fhicl::ParameterSet CompileParameterSet(std::string cfg)
Compiles a parameter set from a string.
template<typename ConfigurationClass >
template<typename Prov >
void testing::TesterEnvironment< ConfigurationClass >::DropProvider ( )
inlineinherited

Removes and destroys the specified provider.

Template Parameters
Provtype of provider to be destroyed
Exceptions
runtime_errorif the provider was not present

Definition at line 917 of file unit_test_base.h.

918  {
919  if (!providers.erase<Prov>()) throw std::runtime_error("Provider not present!");
920  }
bool erase(std::string label="")
Drops the object with the specified type and label.
Definition: ProviderList.h:286
ProviderList providers
list of available providers
template<typename ConfigurationClass >
template<typename... Provs>
void testing::TesterEnvironment< ConfigurationClass >::FillProviderPack ( lar::ProviderPack< Provs... > &  pack) const
inlineinherited

Fills the specified provider pack with providers.

Exceptions
runtime_errorand everything provider() method can throw
See also
Provider()

Definition at line 935 of file unit_test_base.h.

References trkf::fill().

936  {
937  details::ProviderPackFiller<TesterEnv_t, lar::ProviderPack<Provs...>, Provs...>::fill(*this,
938  pack);
939  } // FillProviderPack()
void fill(const art::PtrVector< recob::Hit > &hits, int only_plane)
Container for a list of pointers to providers.
Definition: ProviderPack.h:111
TesterEnvironment< ConfigurationClass > TesterEnv_t
template<typename ConfigurationClass , typename ObjectSorter >
geo::GeometryCore const* testing::GeometryTesterEnvironment< ConfigurationClass, ObjectSorter >::Geometry ( ) const
inlinenoexcept

Definition at line 218 of file geometry_unit_test_base.h.

219  {
220  return this->template Provider<geo::GeometryCore>();
221  }
template<typename ConfigurationClass >
fhicl::ParameterSet const& testing::BasicTesterEnvironment< ConfigurationClass >::Parameters ( ) const
inlineinherited

Returns the full configuration.

Definition at line 607 of file unit_test_base.h.

607 { return params; }
fhicl::ParameterSet params
full configuration of the test
template<typename ConfigurationClass >
fhicl::ParameterSet testing::BasicTesterEnvironment< ConfigurationClass >::ParseParameters ( std::string  config_path)
staticprotectedinherited

Fills the test configuration from file or from default.

Returns the configuration from a FHiCL file.

If a FHiCL configuration file is specified, the configuration of the test is read from it according to the parameter set path of the test. Otherwise, it is parsed from the default one provided by the configurer.Parses from file and returns a FHiCL data structure


Parameters
config_pathfull path of the FHiCL configuration file
Returns
a parameters set with the complete configuration from the file

Definition at line 1049 of file unit_test_base.h.

References fhicl::ParameterSet::make(), and fhicl::parse_document().

1051  {
1052  // configuration file lookup policy
1053  char const* fhicl_env = getenv("FHICL_FILE_PATH");
1054  std::string search_path = fhicl_env ? std::string(fhicl_env) + ":" : ".:";
1055  cet::filepath_first_absolute_or_lookup_with_dot policy(search_path);
1056 
1057  // parse a configuration file; obtain intermediate form
1058  auto table = fhicl::parse_document(config_path, policy);
1059  return fhicl::ParameterSet::make(table);
1060  }
static ParameterSet make(intermediate_table const &tbl)
Definition: ParameterSet.cc:68
intermediate_table parse_document(std::string const &filename, cet::filepath_maker &maker)
Definition: parse.cc:709
template<typename ConfigurationClass >
template<typename Prov >
Prov const* testing::TesterEnvironment< ConfigurationClass >::Provider ( ) const
inlineinherited

Return the specified provider (throws if not available)

Definition at line 924 of file unit_test_base.h.

925  {
926  return providers.getPointer<Prov>();
927  }
T const * getPointer(std::string label="") const
Retrieve the object of type T stored with the specified label.
Definition: ProviderList.h:358
ProviderList providers
list of available providers
template<typename ConfigurationClass >
template<typename Prov >
Prov::providers_type testing::TesterEnvironment< ConfigurationClass >::ProviderPackFor ( ) const
inlineinherited

Returns a provider pack for the specified provider.

Template Parameters
Provtype of the provider
Exceptions
runtime_errorand everything provider() method can throw
See also
FillProviderPack()

The provider is required to have a providers_type type defined as an specialisation of lar::ProviderPack.

Definition at line 951 of file unit_test_base.h.

952  {
953  typename Prov::providers_type pack;
954  FillProviderPack(pack);
955  return pack;
956  } // ProviderPackFor()
void FillProviderPack(lar::ProviderPack< Provs... > &pack) const
Fills the specified provider pack with providers.
template<typename ConfigurationClass >
fhicl::ParameterSet testing::BasicTesterEnvironment< ConfigurationClass >::ServiceParameters ( std::string  service_name) const
inlineinherited

Returns the configuration of the specified service.

Definition at line 610 of file unit_test_base.h.

References fhicl::ParameterSet::get().

611  {
612  return params.get<fhicl::ParameterSet>(config.ServiceParameterSetPath(service_name));
613  }
fhicl::ParameterSet params
full configuration of the test
Configuration_t config
instance of the configurer
T get(std::string const &key) const
Definition: ParameterSet.h:314
template<typename ConfigurationClass , typename ObjectSorter >
void testing::GeometryTesterEnvironment< ConfigurationClass, ObjectSorter >::Setup ( )
protectedvirtual

The complete initialization, ran at construction by default.

Reimplemented from testing::BasicTesterEnvironment< ConfigurationClass >.

Definition at line 283 of file geometry_unit_test_base.h.

284  {
287  mf::LogInfo("Test") << config.ApplicationName() << " Geometry setup complete.";
288  }
virtual std::unique_ptr< geo::GeometryCore > CreateNewGeometry() const
Creates a new geometry.
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
Prov * AcquireProvider(std::unique_ptr< Prov > &&prov)
Acquires a service provider.
virtual void Setup()
The complete initialization, ran at construction by default.
ConfigurationClass config
instance of the configurer
template<typename ConfigurationClass >
void testing::BasicTesterEnvironment< ConfigurationClass >::SetupMessageFacility ( fhicl::ParameterSet const &  pset,
std::string  appl_name = "" 
) const
protectedvirtualinherited

Sets up the message facility.

Sets the message facility up.


Message facility configuration is expected in "services.message" parameter set. If not there, the default configuration is used.

Definition at line 1090 of file unit_test_base.h.

References fhicl::ParameterSet::get_if_present(), MF_LOG_TRACE, mf::SetApplicationName(), mf::SetContextIteration(), mf::SetContextSinglet(), mf::StartMessageFacility(), and fhicl::ParameterSet::to_indented_string().

1093  {
1094  fhicl::ParameterSet mf_pset;
1095 
1096  if (!pset.get_if_present(config.ServiceParameterSetPath("message"), mf_pset)) {
1097  mf_pset = CompileParameterSet(config.DefaultServiceConfiguration("message"));
1098  std::cout << "Using default message facility configuration:\n"
1099  << mf_pset.to_indented_string(1) << std::endl;
1100  } // if no configuration is available
1101 
1102  mf::StartMessageFacility(mf_pset);
1103  if (!appl_name.empty()) mf::SetApplicationName(appl_name);
1104  mf::SetContextIteration("Initialization");
1105  if (options.MessageLevels) {
1106  std::cout << "Printing message levels in 'MessageFacility' category." << std::endl;
1107 
1108  mf::LogProblem("MessageFacility") << "Error messages are shown.";
1109  mf::LogPrint("MessageFacility") << "Warning messages are shown.";
1110  mf::LogVerbatim("MessageFacility") << "Info messages are shown.";
1111  mf::LogTrace("MessageFacility") << "Debug messages are shown.";
1112  MF_LOG_TRACE("MessageFacility")
1113  << "MF_LOG_TRACE/MF_LOG_DEBUG messages are not compiled away.";
1114  } // if print message levels
1115  mf::LogInfo("MessageFacility") << "MessageFacility started.";
1116  mf::SetContextSinglet("main");
1117  }
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
Options_t options
options for the test environment
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
Configuration_t config
instance of the configurer
void SetContextIteration(string const &val)
MaybeLogger_< ELseverityLevel::ELsev_error, true > LogProblem
void StartMessageFacility(fhicl::ParameterSet const &pset, string const &applicationName)
#define MF_LOG_TRACE(id)
std::string to_indented_string() const
bool MessageLevels
print message levels on screen
void SetContextSinglet(string const &val)
MaybeLogger_< ELseverityLevel::ELsev_success, true > LogTrace
static fhicl::ParameterSet CompileParameterSet(std::string cfg)
Compiles a parameter set from a string.
void SetApplicationName(string const &applicationName)
MaybeLogger_< ELseverityLevel::ELsev_warning, true > LogPrint
template<typename ConfigurationClass >
virtual void testing::BasicTesterEnvironment< ConfigurationClass >::SetupMessageFacility ( ) const
inlineprotectedvirtualinherited

Sets up the message facility.

Sets the message facility up.


Message facility configuration is expected in "services.message" parameter set. If not there, the default configuration is used.

Definition at line 657 of file unit_test_base.h.

References lar::standalone::SetupMessageFacility().

658  {
659  SetupMessageFacility(Parameters(), config.ApplicationName());
660  }
fhicl::ParameterSet const & Parameters() const
Returns the full configuration.
Configuration_t config
instance of the configurer
virtual void SetupMessageFacility() const
Sets up the message facility.
template<typename ConfigurationClass >
template<typename Prov , typename... Args>
Prov* testing::TesterEnvironment< ConfigurationClass >::SetupProvider ( Args &&...  args)
inlineinherited

Sets a service provider up by calling its testing::setupProvider()

Template Parameters
Provtype of provider
Argstype of arguments for the setup function
Parameters
argsarguments for the setup function
Returns
a pointer to the provider set up
Exceptions
runtime_errorif the provider already exists
See also
SetupProviderFor(), AcquireProvider()

A provider of type Prov is created, set up and recorded. Provider setup is delegated to testing::setupProvider function specific to the provider itself (that is, testing::setupProvider<Prov>(args...)) to which the setup arguments are forwarded. If the provider already exists, an exception is thrown.

Definition at line 773 of file unit_test_base.h.

References testing::details::CommandLineArguments::args.

774  {
775  if (!providers.setup<Prov>(std::forward<Args>(args)...))
776  throw std::runtime_error("Provider already exists!");
777  return providers.getPointer<Prov>();
778  }
T const * getPointer(std::string label="") const
Retrieve the object of type T stored with the specified label.
Definition: ProviderList.h:358
ProviderList providers
list of available providers
bool setup(Args &&...args)
Construct and register an object of type T with specified arguments.
Definition: ProviderList.h:249
template<typename ConfigurationClass >
template<typename Interface , typename Prov , typename... Args>
Prov* testing::TesterEnvironment< ConfigurationClass >::SetupProviderFor ( Args &&...  args)
inlineinherited

Sets a provider up, recording it as implementation of Interface.

Template Parameters
Interfacetype of provider interface being implemented
Provtype of provider
Argstype of arguments for the setup function
Parameters
argsarguments for the setup function
Returns
a pointer to the provider set up
See also
SetupProvider()

This method performs the same type of setup as SetupProvider(). In addition, it registers the provider as an implementation of Interface. This means that the provider can be obtained not only with provider<Prov>(), which returns a pointer to the actual class Prov, but also as provider<Interface>(), which returns a pointer to the base class Interface.

Definition at line 836 of file unit_test_base.h.

References testing::details::CommandLineArguments::args.

837  {
838  auto prov = SetupProvider<Prov>(std::forward<Args>(args)...);
839  providers.set_alias<Prov, Interface>();
840  return prov;
841  }
ProviderList providers
list of available providers
bool set_alias(std::string alias_label="", std::string prov_label="")
Sets the Alias type as an alias of the Prov provider (with labels)
Definition: ProviderList.h:306
template<typename ConfigurationClass >
template<typename Prov , typename... Args>
Prov* testing::TesterEnvironment< ConfigurationClass >::SetupProviderFromService ( std::string  name,
Args &&...  args 
)
inlineinherited

Sets a service provider up by calling its testing::setupProvider()

Template Parameters
Provtype of provider
Argstype of arguments for the setup function
Parameters
namethe service name (for configuration retrieval)
argsarguments for the setup function
Returns
a pointer to the provider set up
See also
SetupProvider()
Exceptions
runtime_errorif the provider already exists

A provider of type Prov is created, set up and recorded. Provider setup is attempted by constructing the provider with a parameter set from the registered configuration of service with specified name.

Definition at line 795 of file unit_test_base.h.

References testing::details::CommandLineArguments::args.

796  {
797  return SetupProvider<Prov>(this->ServiceParameters(name, std::forward<Args>(args)...));
798  }
fhicl::ParameterSet ServiceParameters(std::string service_name) const
Returns the configuration of the specified service.
template<typename ConfigurationClass >
template<typename Interface , typename Prov , typename... Args>
Prov* testing::TesterEnvironment< ConfigurationClass >::SetupProviderFromServiceFor ( std::string  name,
Args &&...  args 
)
inlineinherited

Sets a provider up, recording it as implementation of Interface.

Template Parameters
Interfacetype of provider interface being implemented
Provtype of provider
Argstype of arguments for the setup function
Parameters
namethe service name (for configuration retrieval)
argsarguments for the setup function
Returns
a pointer to the provider set up
See also
SetupProviderFromService(), SetupProviderFor()
Exceptions
runtime_errorif the provider already exists

This method performs the same type of setup as SetupProviderFromService(). In addition, it registers the provider as an implementation of Interface. This means that the provider can be obtained not only with provider<Prov>(), which returns a pointer to the actual class Prov, but also as provider<Interface>(), which returns a pointer to the base class Interface.

Definition at line 863 of file unit_test_base.h.

References testing::details::CommandLineArguments::args.

864  {
865  auto* prov = SetupProviderFromService<Prov>(name, std::forward<Args>(args)...);
866  providers.set_alias<Prov, Interface>();
867  return prov;
868  }
ProviderList providers
list of available providers
bool set_alias(std::string alias_label="", std::string prov_label="")
Sets the Alias type as an alias of the Prov provider (with labels)
Definition: ProviderList.h:306
template<typename ConfigurationClass >
template<typename Prov >
Prov* testing::TesterEnvironment< ConfigurationClass >::SimpleProviderSetup ( )
inlineinherited

Oversimplified provider setup.

Returns
a pointer to the provider
Template Parameters
Provprovider type

This is a one-step setup of the specified provider.

It is available only if Prov provider comes with an implementation of testing::SimpleEnvironmentSetupClass that explains how to set up an environment.

Definition at line 906 of file unit_test_base.h.

907  {
908  return simpleEnvironmentSetup<Prov>(*this);
909  }
template<typename ConfigurationClass >
fhicl::ParameterSet testing::BasicTesterEnvironment< ConfigurationClass >::TesterParameters ( std::string  test_name) const
inlineinherited

Returns the configuration of the specified test.

Definition at line 616 of file unit_test_base.h.

References fhicl::ParameterSet::get().

617  {
618  return params.get<fhicl::ParameterSet>(config.TesterParameterSetPath(test_name));
619  }
fhicl::ParameterSet params
full configuration of the test
Configuration_t config
instance of the configurer
T get(std::string const &key) const
Definition: ParameterSet.h:314
template<typename ConfigurationClass >
fhicl::ParameterSet testing::BasicTesterEnvironment< ConfigurationClass >::TesterParameters ( ) const
inlineinherited

Returns the configuration of the main test (undefined if no main test)

Definition at line 622 of file unit_test_base.h.

623  {
624  if (config.MainTesterParameterSetName().empty())
625  return {};
626  else
627  return TesterParameters(config.MainTesterParameterSetName());
628  }
Configuration_t config
instance of the configurer
fhicl::ParameterSet TesterParameters() const
Returns the configuration of the main test (undefined if no main test)

Member Data Documentation

template<typename ConfigurationClass , typename ObjectSorter >
ConfigurationClass testing::GeometryTesterEnvironment< ConfigurationClass, ObjectSorter >::config
private

instance of the configurer

Definition at line 234 of file geometry_unit_test_base.h.

template<typename ConfigurationClass >
ProviderList testing::TesterEnvironment< ConfigurationClass >::providers
protectedinherited

list of available providers

Definition at line 959 of file unit_test_base.h.


The documentation for this class was generated from the following file: