mirror of https://github.com/google/benchmark.git
Issue 1734: Streams not flushed if not running actual benchmarks (#1735)
Consistently flush Out and Err streams, otherwise they might not get flushed and the output lost when using custom streams. Fixes #1734.
This commit is contained in:
parent
96d820f73f
commit
54e4327190
|
@ -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) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -611,6 +621,8 @@ size_t RunSpecifiedBenchmarks(BenchmarkReporter* display_reporter,
|
|||
internal::RunBenchmarks(benchmarks, display_reporter, file_reporter);
|
||||
}
|
||||
|
||||
Out.flush();
|
||||
Err.flush();
|
||||
return benchmarks.size();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue