MCPcopy Create free account
hub / github.com/bombela/backward-cpp / main

Function main

test/_test_main.cpp:188–241  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

186}
187
188int main(int argc, const char *const argv[]) {
189
190#ifdef _WIN32
191 _set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
192#endif
193
194 if (argc == 3 && strcmp("--nofork", argv[1]) == 0) {
195 // Windows has no fork, so we simulate it
196 // we only execute one test, without forking
197 for (test_registry_t::iterator it = test_registry().begin();
198 it != test_registry().end(); ++it) {
199 TestBase &test = **it;
200 if (strcasecmp(argv[2], test.name) == 0) {
201 run_test(test, false);
202
203 return 0;
204 }
205 }
206 return -1;
207 }
208
209 size_t success_cnt = 0;
210 size_t total_cnt = 0;
211 for (test_registry_t::iterator it = test_registry().begin();
212 it != test_registry().end(); ++it) {
213 TestBase &test = **it;
214
215 bool consider_test = (argc <= 1);
216 for (int i = 1; i < argc; ++i) {
217 if (strcasecmp(argv[i], test.name) == 0) {
218 consider_test = true;
219 break;
220 }
221 }
222 if (!consider_test) {
223 continue;
224 }
225
226 total_cnt += 1;
227 if (run_test(test)) {
228 printf("-- test case success: %s\n", test.name);
229 success_cnt += 1;
230 } else {
231 printf("** test case FAILED : %s\n", test.name);
232 }
233 }
234 printf("-- tests passing: %zu/%zu", success_cnt, total_cnt);
235 if (total_cnt) {
236 printf(" (%zu%%)\n", success_cnt * 100 / total_cnt);
237 } else {
238 printf("\n");
239 }
240 return (success_cnt == total_cnt) ? EXIT_SUCCESS : EXIT_FAILURE;
241}

Callers

nothing calls this directly

Calls 2

run_testFunction · 0.85
beginMethod · 0.80

Tested by

no test coverage detected