MCPcopy Create free account
hub / github.com/davisking/dlib / main

Function main

dlib/test/main.cpp:20–213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18static logger dlog("test.main");
19
20int main (int argc, char** argv)
21{
22 try
23 {
24 clp parser;
25
26 parser.add_option("runall","Run all the tests that don't take any arguments.");
27 parser.add_option("h","Displays this information.");
28 parser.add_option("n","How many times to run the selected tests. The default is 1.",1);
29 parser.add_option("d","log debugging statements to file debug.txt.");
30 parser.add_option("l","Set the logging level (all, trace, debug, info, warn, error, or fatal), the default is all.",1);
31 parser.add_option("a","Append debugging messages to debug.txt rather than clearing the file at program startup.");
32 parser.add_option("q","Be quiet. Don't print the testing progress or non-failure results to standard out.");
33
34 unsigned long num = 1;
35
36 // add the options for all the different tests
37 for (auto& kv : testers())
38 {
39 tester& test = *kv.second;
40 parser.add_option(test.cmd_line_switch(), test.description(), test.num_of_args());
41 if (test.num_of_args()==0)
42 parser.add_option("no_"+test.cmd_line_switch(), "Don't run this option when using --runall.");
43 }
44
45 parser.parse(argc,argv);
46
47 parser.check_option_arg_range("n",1,1000000000);
48 const char* singles[] = {"d","l","a","n","h","runall","q"};
49 parser.check_one_time_options(singles);
50 const char* d_sub[] = {"l","a"};
51 const char* l_args[] = {"all", "trace", "debug", "info", "warn", "error", "fatal"};
52 parser.check_sub_options("d",d_sub);
53 parser.check_option_arg_range("l",l_args);
54
55
56 if (parser.option("n"))
57 {
58 num = string_cast<unsigned long>(parser.option("n").argument());
59 }
60
61 if (parser.option("q"))
62 {
63 be_verbose = false;
64 }
65
66 if (parser.option("h"))
67 {
68 cout << "Usage: test [options]\n";
69 parser.print_options(cout);
70 cout << "\n\n";
71 return 0;
72 }
73
74 ofstream fout;
75 if (parser.option("d"))
76 {
77 if (parser.option("a"))

Callers

nothing calls this directly

Calls 9

set_all_logging_levelsFunction · 0.85
parseMethod · 0.80
print_optionsMethod · 0.80
countMethod · 0.80
openMethod · 0.45
perform_testMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected