MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / runTests

Method runTests

test/fixture.cpp:399–448  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

397}
398
399std::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
450void TestFixture::reportOut(const std::string & outmsg, Color /*c*/)
451{

Callers

nothing calls this directly

Calls 11

processOptionsMethod · 0.80
runFunction · 0.50
strMethod · 0.45
exclude_testsMethod · 0.45
emptyMethod · 0.45
findMethod · 0.45
createMethod · 0.45
timer_resultsMethod · 0.45
runMethod · 0.45
summaryMethod · 0.45
dry_runMethod · 0.45

Tested by

no test coverage detected