Skip to content

Commit

Permalink
Report error when no benchmarks match regex. (#308)
Browse files Browse the repository at this point in the history
Fixes #306
  • Loading branch information
dominichamon authored Oct 28, 2016
1 parent 0064c56 commit 4f8bfea
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/benchmark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ void State::FinishKeepRunning() {
namespace internal {
namespace {

void RunMatchingBenchmarks(const std::vector<Benchmark::Instance>& benchmarks,
void RunBenchmarks(const std::vector<Benchmark::Instance>& benchmarks,
BenchmarkReporter* console_reporter,
BenchmarkReporter* file_reporter) {
// Note the file_reporter can be null.
Expand Down Expand Up @@ -581,11 +581,15 @@ size_t RunSpecifiedBenchmarks(BenchmarkReporter* console_reporter,
std::vector<internal::Benchmark::Instance> benchmarks;
if (!FindBenchmarksInternal(spec, &benchmarks, &Err)) return 0;

if (benchmarks.empty()) {
Err << "Failed to match any benchmarks against regex: " << spec << "\n";
return 0;
}

if (FLAGS_benchmark_list_tests) {
for (auto const& benchmark : benchmarks) Out << benchmark.name << "\n";
} else {
internal::RunMatchingBenchmarks(benchmarks, console_reporter,
file_reporter);
internal::RunBenchmarks(benchmarks, console_reporter, file_reporter);
}

return benchmarks.size();
Expand Down

0 comments on commit 4f8bfea

Please sign in to comment.