| 571 | } |
| 572 | |
| 573 | int NBench::Main(int argc, char** argv) { |
| 574 | const TProgOpts opts(argc, argv); |
| 575 | |
| 576 | TVector<ITestRunner*> tests; |
| 577 | |
| 578 | for (auto&& it : Tests()) { |
| 579 | if (opts.MatchFilters(it.Name())) { |
| 580 | tests.push_back(&it); |
| 581 | } |
| 582 | } |
| 583 | EnumerateTests(tests); |
| 584 | |
| 585 | if (opts.ListTests) { |
| 586 | for (const auto* const it : tests) { |
| 587 | Cout << it->Name() << Endl; |
| 588 | } |
| 589 | |
| 590 | return 0; |
| 591 | } |
| 592 | |
| 593 | if (!tests) { |
| 594 | return 0; |
| 595 | } |
| 596 | |
| 597 | double timeBudget = opts.TimeBudget; |
| 598 | |
| 599 | if (timeBudget < 0) { |
| 600 | timeBudget = 5.0 * tests.size(); |
| 601 | } |
| 602 | |
| 603 | |
| 604 | THolder<IOutputStream> outputHolder; |
| 605 | IOutputStream* outputStream = &Cout; |
| 606 | |
| 607 | if (opts.ReportPath != "") { |
| 608 | TString filePath(opts.ReportPath); |
| 609 | outputHolder.Reset(outputStream = new TFileOutput(filePath)); |
| 610 | } |
| 611 | |
| 612 | const TOptions testOpts = {timeBudget / tests.size()}; |
| 613 | const auto reporter = MakeOrderedReporter(opts.OutFormat, *outputStream); |
| 614 | |
| 615 | std::function<void(ITestRunner**)> func = [&](ITestRunner** it) { |
| 616 | auto&& res = (*it)->Run(testOpts); |
| 617 | |
| 618 | reporter->Report(std::move(res)); |
| 619 | }; |
| 620 | |
| 621 | if (opts.Threads > 1) { |
| 622 | NYmp::SetThreadCount(opts.Threads); |
| 623 | NYmp::ParallelForStaticChunk(tests.data(), tests.data() + tests.size(), 1, func); |
| 624 | } else { |
| 625 | for (auto it : tests) { |
| 626 | func(&it); |
| 627 | } |
| 628 | } |
| 629 | |
| 630 | reporter->Finish(); |
nothing calls this directly
no test coverage detected