Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 1734: Streams not flushed if not running actual benchmarks #1735

Merged
merged 3 commits into from
Jan 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/benchmark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -577,12 +577,16 @@ size_t RunSpecifiedBenchmarks(BenchmarkReporter* display_reporter,
Err << "A custom file reporter was provided but "
"--benchmark_out=<file> was not specified."
<< std::endl;
Out.flush();
Err.flush();
std::exit(1);
}
if (!fname.empty()) {
output_file.open(fname);
if (!output_file.is_open()) {
Err << "invalid file name: '" << fname << "'" << std::endl;
Out.flush();
Err.flush();
std::exit(1);
}
if (!file_reporter) {
Expand All @@ -597,10 +601,16 @@ size_t RunSpecifiedBenchmarks(BenchmarkReporter* display_reporter,
}

std::vector<internal::BenchmarkInstance> benchmarks;
if (!FindBenchmarksInternal(spec, &benchmarks, &Err)) return 0;
if (!FindBenchmarksInternal(spec, &benchmarks, &Err)) {
Out.flush();
Err.flush();
return 0;
}

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

Expand All @@ -611,6 +621,8 @@ size_t RunSpecifiedBenchmarks(BenchmarkReporter* display_reporter,
internal::RunBenchmarks(benchmarks, display_reporter, file_reporter);
}

Out.flush();
Err.flush();
return benchmarks.size();
}

Expand Down
Loading