fix: silence gcov's per-file summary under bazel coverage - #241
Merged
Merged
Conversation
Bazel's collect_cc_coverage.sh invokes gcov without redirecting its stdout (it declares gcov_log but never uses it, still unfixed on Bazel master), so the per-file summary of the test's whole transitive C++ closure lands in the test's test.log. For large closures that is megabytes of 'Lines executed:0.00%' noise that buries the test's own output and can overflow Bazel's --experimental_ui_max_stdouterr_bytes, hiding real failures. Bazel only consumes the .gcov.json.gz data files gcov writes to disk, never its stdout, so the wrapper now drops stdout when the wrapped tool is gcov running under a Bazel coverage test action (COVERAGE_DIR is only set there). stderr is left alone so real gcov errors still surface.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Bazel's
collect_cc_coverage.shinvokes gcov without redirecting its stdout: the script declaresgcov_logwith a comment promising to save gcov's output there, but the variable is never used (still unfixed on Bazel master). gcov's per-file summary for the test's whole transitive C++ closure therefore lands in the test'stest.log.For large closures (e.g. pybind-heavy Python tests) this is megabytes of
Lines executed:0.00%noise per test — one observed test.log was 9.2 MB with 237k gcov summary lines and 2 lines of actual test output. It buries the test's own output and can overflow--experimental_ui_max_stdouterr_bytes, at which point Bazel prints nothing at all for a failing test.gcov itself has no quiet flag (
-qis--use-hotness-colors), so the wrapper is the right interposition point.Fix
Before the final
exec, when the wrapped tool is gcov andCOVERAGE_DIRis set (only true inside a Bazel coverage test action), redirect stdout to/dev/null. Bazel only consumes the.gcov.json.gzdata files gcov writes to disk, never its stdout. stderr is untouched so real gcov errors still surface. All other tools wrapped by the same template are unaffected.Verification
Ran
bazel coverageon a downstream repo with--override_repository=gcc_toolchain=<this checkout>:bazel test