| 397 | } |
| 398 | |
| 399 | std::size_t TestFixture::runTests(const options& args) |
| 400 | { |
| 401 | countTests = 0; |
| 402 | errmsg.str(""); |
| 403 | |
| 404 | const auto& which_tests = args.which_tests(); |
| 405 | const auto exclude_tests = args.exclude_tests(); |
| 406 | |
| 407 | // TODO: bail out when given class/test is not found? |
| 408 | for (TestInstance * test : TestRegistry::theInstance().tests()) |
| 409 | { |
| 410 | std::set<std::string> tests; |
| 411 | if (!which_tests.empty()) { |
| 412 | const auto it = which_tests.find(test->classname); |
| 413 | const bool match = it != which_tests.cend(); |
| 414 | if (match && exclude_tests && it->second.empty()) // only bailout when the whole fixture is excluded |
| 415 | continue; |
| 416 | if (!match && !exclude_tests) |
| 417 | continue; |
| 418 | if (match) |
| 419 | tests = it->second; |
| 420 | } |
| 421 | |
| 422 | TestFixture* fixture; |
| 423 | const auto f = [&](){ |
| 424 | fixture = test->create(); |
| 425 | }; |
| 426 | Timer::run(test->classname + " - create", args.timer_results(), f); |
| 427 | fixture->processOptions(args); |
| 428 | fixture->run(tests); |
| 429 | } |
| 430 | |
| 431 | if (args.summary() && !args.dry_run()) { |
| 432 | std::cout << "\n\nTesting Complete\nNumber of tests: " << countTests << std::endl; |
| 433 | std::cout << "Number of todos: " << todos_counter; |
| 434 | if (succeeded_todos_counter > 0) |
| 435 | std::cout << " (" << succeeded_todos_counter << " succeeded)"; |
| 436 | std::cout << std::endl; |
| 437 | } |
| 438 | // calling flush here, to do all output before the error messages (in case the output is buffered) |
| 439 | std::cout.flush(); |
| 440 | |
| 441 | if (args.summary() && !args.dry_run()) { |
| 442 | std::cerr << "Tests failed: " << fails_counter << std::endl << std::endl; |
| 443 | } |
| 444 | std::cerr << errmsg.str(); |
| 445 | |
| 446 | std::cerr.flush(); |
| 447 | return fails_counter + succeeded_todos_counter; |
| 448 | } |
| 449 | |
| 450 | void TestFixture::reportOut(const std::string & outmsg, Color /*c*/) |
| 451 | { |
nothing calls this directly
no test coverage detected