Skip to content

Commit

Permalink
Change set -x in coverage to be set by var
Browse files Browse the repository at this point in the history
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 bazelbuild#13248.

PiperOrigin-RevId: 369396233
  • Loading branch information
keith authored and copybara-github committed Apr 20, 2021
1 parent d743e57 commit 615e1b1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion tools/test/collect_cc_coverage.sh
Original file line number Diff line number Diff line change
@@ -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");
Expand Down Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion tools/test/collect_coverage.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash -x
#!/bin/bash

# Copyright 2016 The Bazel Authors. All rights reserved.
#
Expand All @@ -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"

Expand Down

0 comments on commit 615e1b1

Please sign in to comment.