LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
catch_main.cc File Reference
#include "catch/catch.hpp"
#include "cetlib/filepath_maker.h"
#include "fhiclcpp/ParameterSet.h"
#include "fhiclcpp/make_ParameterSet.h"
#include "messagefacility/MessageLogger/MessageLogger.h"
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>

Go to the source code of this file.

Macros

#define CATCH_CONFIG_RUNNER
 

Functions

void usage (Catch::Session &session, string processName)
 
string processOptions (Catch::Session &session, int &argc, char **&argv)
 
int main (int argc, char **argv)
 

Macro Definition Documentation

#define CATCH_CONFIG_RUNNER

Definition at line 2 of file catch_main.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 56 of file catch_main.cc.

References fhicl::make_ParameterSet(), processOptions(), s, mf::SetIteration(), and mf::StartMessageFacility().

57 {
58  Catch::Session catchSession;
59  auto const fhiclConfigFileName = processOptions(catchSession, argc, argv);
60  int result = catchSession.applyCommandLine(argc, argv);
61  if (result == 0) {
62  mf::SetIteration("JobSetup"s);
63  fhicl::ParameterSet msg_ps;
64  cet::filepath_maker fpm;
65  fhicl::make_ParameterSet(fhiclConfigFileName, fpm, msg_ps);
67  result = catchSession.run();
68  }
69  return (result < 0xff ? result : 0xff);
70 }
Float_t s
Definition: plot.C:23
void SetIteration(string const &val)
string processOptions(Catch::Session &session, int &argc, char **&argv)
Definition: catch_main.cc:29
void make_ParameterSet(intermediate_table const &tbl, ParameterSet &ps)
void StartMessageFacility(fhicl::ParameterSet const &pset, string const &applicationName)
string processOptions ( Catch::Session &  session,
int &  argc,
char **&  argv 
)

Definition at line 29 of file catch_main.cc.

References usage().

Referenced by main().

30 {
31  string processName(argv[0]);
32  auto slashPos = processName.find_last_of('/');
33  if (slashPos == string::npos) {
34  slashPos = 0ull;
35  }
36  if (slashPos > 0ull && slashPos < (processName.size() - 1)) {
37  processName = processName.substr(slashPos + 1);
38  }
39  string fhiclConfigFileName;
40  if (argc < 2) {
41  cout << "ERROR: expected at least one argument.\n\n";
42  usage(session, processName);
43  } else if ((strcmp("-h", argv[1]) == 0) ||
44  (strncmp("--h", argv[1], 3) == 0)) {
45  usage(session, processName);
46  } else {
47  fhiclConfigFileName = argv[1];
48  argv[1] = argv[0];
49  --argc;
50  ++argv;
51  }
52  return fhiclConfigFileName;
53 }
static G4UIterminal * session
void usage(Catch::Session &session, string processName)
Definition: catch_main.cc:19
void usage ( Catch::Session &  session,
string  processName 
)

Definition at line 19 of file catch_main.cc.

Referenced by processOptions().

20 {
21  cout << "usage:\n " << processName << " [-h]\n";
22  cout << " " << processName << " <fhicl-config-file> [catch-options]+\n\n";
23  cout << "Catch usage:" << endl;
24  session.showHelp(processName + " <fhicl-config-file>");
25  exit(1);
26 }
static G4UIterminal * session