Fix build of evoral tests
[ardour.git] / libs / ardour / test / testrunner.cc
1 #include <getopt.h>
2 #include <glibmm/thread.h>
3
4 #include <cppunit/CompilerOutputter.h>
5 #include <cppunit/extensions/TestFactoryRegistry.h>
6 #include <cppunit/TestResult.h>
7 #include <cppunit/TestResultCollector.h>
8 #include <cppunit/TestRunner.h>
9 #include <cppunit/BriefTestProgressListener.h>
10
11 #include "pbd/debug.h"
12 #include "ardour/ardour.h"
13
14 static const char* localedir = LOCALEDIR;
15
16 int
17 main(int argc, char* argv[])
18 {
19         if (!Glib::thread_supported()) {
20                 Glib::thread_init();
21         }
22
23         const struct option longopts[] = {
24                 { "debug", 1, 0, 'D' },
25                 { 0, 0, 0, 0 }
26         };
27         const char *optstring = "D:";
28         int option_index = 0;
29         int c = 0;
30
31         while (1) {
32                 c = getopt_long (argc, argv, optstring, longopts, &option_index);
33
34                 if (c == -1) {
35                         break;
36                 }
37
38                 switch (c) {
39                 case 0:
40                         break;
41
42                 case 'D':
43                         if (PBD::parse_debug_options (optarg)) {
44                                 exit (0);
45                         }
46                         break;
47                 }
48         }
49
50         ARDOUR::init (false, true, localedir);
51         
52         CppUnit::TestResult testresult;
53         
54         CppUnit::TestResultCollector collectedresults;
55         testresult.addListener (&collectedresults);
56         
57         CppUnit::BriefTestProgressListener progress;
58         testresult.addListener (&progress);
59         
60         CppUnit::TestRunner testrunner;
61         testrunner.addTest (CppUnit::TestFactoryRegistry::getRegistry ().makeTest ());
62         testrunner.run (testresult);
63         
64         CppUnit::CompilerOutputter compileroutputter (&collectedresults, std::cerr);
65         compileroutputter.write ();
66
67         ARDOUR::cleanup ();
68         
69         return collectedresults.wasSuccessful () ? 0 : 1;
70 }