Line data Source code
1 : /* Generated file, do not edit */ 2 : 3 : // vim: set filetype=cpp : 4 : 5 : #include <cstring> 6 : #ifndef CXXTEST_RUNNING 7 : #define CXXTEST_RUNNING 8 : #endif 9 : 10 : #define _CXXTEST_HAVE_STD 11 : #define _CXXTEST_HAVE_EH 12 : #include "precompiled.h" 13 : #include <cxxtest/TestListener.h> 14 : #include <cxxtest/TestTracker.h> 15 : #include <cxxtest/TestRunner.h> 16 : #include <cxxtest/RealDescriptions.h> 17 : #include <cxxtest/TestMain.h> 18 : 19 : #include <cxxtest/Descriptions.h> 20 : #include <cxxtest/ErrorPrinter.h> 21 : #include <cxxtest/XmlPrinter.h> 22 : #include <iostream> 23 : #include <ps/DllLoader.h> 24 : #include <string> 25 : 26 0 : void usage(const char* prog) { 27 0 : const std::string help = std::string("Usage: ") + prog + R"( [options] 28 : 29 : --format junit|simple simple: default, good for cli - junit: for use by CI 30 : --help This message 31 : --libdir dir Where to find extra shared libraries, used for running tests in staging area 32 : --list List available test by suite 33 : --output file File to write to, defaults to stdout 34 : --suite suite Only run named suite 35 : --test test Only run named test of given suite 36 : )"; 37 0 : std::printf("%s\n", help.c_str()); 38 0 : } 39 : 40 1 : int main(int argc, char **argv) 41 : { 42 : 43 1 : char* suite = nullptr; 44 1 : char* test = nullptr; 45 1 : bool xml = false; 46 1 : std::ostream* output = &std::cout; 47 1 : std::ofstream out; 48 : 49 1 : for (int i = 1; i < argc; ++i) 50 : { 51 0 : if (std::strcmp(argv[i], "--libdir") == 0) 52 : { 53 0 : if (++i >= argc) 54 : { 55 0 : std::printf("Option libdir requires an optarg\n\n"); 56 0 : usage(argv[0]); 57 : return 1; 58 : } 59 : 60 0 : DllLoader::OverrideLibdir(argv[i]); 61 : } 62 0 : else if (std::strcmp(argv[i], "--format") == 0) 63 : { 64 0 : if (++i >= argc) 65 : { 66 0 : std::printf("Option format requires an optarg\n\n"); 67 0 : usage(argv[0]); 68 : return 1; 69 : } 70 : 71 0 : if (std::strcmp(argv[i], "junit") == 0) 72 : xml = true; 73 0 : else if (std::strcmp(argv[i], "simple") == 0) 74 : xml = false; 75 : else 76 : { 77 0 : std::printf("Unkown format: %s\n\n", argv[i]); 78 0 : usage(argv[0]); 79 : return 1; 80 : } 81 : } 82 0 : else if (std::strcmp(argv[i], "--output") == 0) 83 : { 84 0 : if (++i >= argc) 85 : { 86 0 : std::printf("Option output requires an optarg\n\n"); 87 0 : usage(argv[0]); 88 : return 1; 89 : } 90 : 91 0 : out.open(argv[i]); 92 : output = &out; 93 : } 94 0 : else if (std::strcmp(argv[i], "--list") == 0) 95 : { 96 0 : for (CxxTest::SuiteDescription *sd = CxxTest::RealWorldDescription().firstSuite(); sd; sd = sd->next()) 97 : { 98 0 : std::printf("%s\n", sd->suiteName()); 99 0 : for (CxxTest::TestDescription *td = sd->firstTest(); td; td = td->next()) 100 0 : std::printf(" %s\n", td->testName()); 101 : } 102 : return 0; 103 : } 104 0 : else if (std::strcmp(argv[i], "--suite") == 0) 105 : { 106 0 : if (++i >= argc) 107 : { 108 0 : std::printf("Option suite requires an optarg\n\n"); 109 0 : usage(argv[0]); 110 : return 1; 111 : } 112 0 : suite = argv[i]; 113 : } 114 0 : else if (std::strcmp(argv[i], "--test") == 0) 115 : { 116 0 : if (++i >= argc) 117 : { 118 0 : std::printf("Option test requires an optarg\n\n"); 119 0 : usage(argv[0]); 120 : return 1; 121 : } 122 0 : test = argv[i]; 123 : } 124 0 : else if (std::strcmp(argv[i], "--help") == 0) 125 : { 126 0 : usage(argv[0]); 127 : return 0; 128 : } 129 : else 130 : { 131 0 : std::printf("Unkown argument: %s\n\n", argv[i]); 132 0 : usage(argv[0]); 133 : return 1; 134 : } 135 : } 136 : 137 1 : if (test) 138 : { 139 0 : if (!suite) 140 : { 141 0 : std::printf("test needs a suite specified\n\n"); 142 0 : usage(argv[0]); 143 : return 1; 144 : } 145 0 : if (!CxxTest::leaveOnly(suite, test)) 146 : { 147 0 : std::printf("Unknown test '%s' in suite '%s'\n\n", test, suite); 148 0 : usage(argv[0]); 149 : return 1; 150 : } 151 : } 152 1 : else if (suite) 153 : { 154 0 : if (!CxxTest::leaveOnly(suite)) 155 : { 156 0 : std::printf("Unknown suite '%s'\n\n", suite); 157 0 : usage(argv[0]); 158 : return 1; 159 : } 160 : } 161 : 162 1 : if (xml) 163 0 : return CxxTest::XmlPrinter(*output).run(); 164 : 165 3 : return CxxTest::ErrorPrinter(*output).run(); 166 1 : } 167 : 168 : // The CxxTest "world" 169 : #include <cxxtest/Root.cpp> 170 : const char* CxxTest::RealWorldDescription::_worldName = "cxxtest";