From 6d28486e8eca70f76d13922944cb567b8aa09380 Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Tue, 20 Apr 2021 02:10:23 -0700 Subject: [PATCH] Change `set -x` in coverage to be set by var Using `set -x` in the coverage scripts causes a lot of noise, this changes it to be off by default, but something you can enable by passing `--test_env=VERBOSE_COVERAGE=1` for debugging. Closes #13248. PiperOrigin-RevId: 369396233 --- tools/test/collect_cc_coverage.sh | 7 ++++++- tools/test/collect_coverage.sh | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/tools/test/collect_cc_coverage.sh b/tools/test/collect_cc_coverage.sh index 00d824c1c0a3e6..c339659961abbf 100755 --- a/tools/test/collect_cc_coverage.sh +++ b/tools/test/collect_cc_coverage.sh @@ -1,4 +1,4 @@ -#!/bin/bash -x +#!/bin/bash # Copyright 2016 The Bazel Authors. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -31,11 +31,16 @@ # - COVERAGE_GCOV_OPTIONS Additional options to pass to gcov. # - ROOT Location from where the code coverage collection # was invoked. +# - VERBOSE_COVERAGE Print debug info from the coverage scripts # # The script looks in $COVERAGE_DIR for the C++ metadata coverage files (either # gcda or profraw) and uses either lcov or gcov to get the coverage data. # The coverage data is placed in $COVERAGE_OUTPUT_FILE. +if [[ -n "$VERBOSE_COVERAGE" ]]; then + set -x +fi + # Checks if clang llvm coverage should be used instead of lcov. function uses_llvm() { if stat "${COVERAGE_DIR}"/*.profraw >/dev/null 2>&1; then diff --git a/tools/test/collect_coverage.sh b/tools/test/collect_coverage.sh index a5f69a0531a352..23d0198a21b727 100755 --- a/tools/test/collect_coverage.sh +++ b/tools/test/collect_coverage.sh @@ -1,4 +1,4 @@ -#!/bin/bash -x +#!/bin/bash # Copyright 2016 The Bazel Authors. All rights reserved. # @@ -21,10 +21,15 @@ # LCOV_MERGER - mandatory, location of the LcovMerger # COVERAGE_DIR - optional, location of the coverage temp directory # COVERAGE_OUTPUT_FILE - optional, location of the final lcov file +# VERBOSE_COVERAGE - optional, print debug info from the coverage scripts # # Script expects that it will be started in the execution root directory and # not in the test's runfiles directory. +if [[ -n "$VERBOSE_COVERAGE" ]]; then + set -x +fi + function resolve_links() { local name="$1"