Always emit coverage, even if the exe returns non-zero
Coverage can be useful for debugging unfamiliar code. If the bug causes a non-zero exit, then we still want the coverage to be generated.
Change-Id: I2d218cd4bb1395c71553e1baab78fb6ca9d41cca
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35422
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
diff --git a/tools/tint-generate-coverage b/tools/tint-generate-coverage
index e1bef24..b7ff48b 100755
--- a/tools/tint-generate-coverage
+++ b/tools/tint-generate-coverage
@@ -15,8 +15,6 @@
# See https://clang.llvm.org/docs/SourceBasedCodeCoverage.html
-set -e # Fail on any error.
-
if [ ! -x "$(which llvm-profdata)" ] ; then
echo "error: llvm-profdata needs to be on \$PATH to use $0"
exit 1
@@ -50,6 +48,9 @@
# https://clang.llvm.org/docs/SourceBasedCodeCoverage.html#running-the-instrumented-program
LLVM_PROFILE_FILE="${PROFRAW_FILE}" $@
+# Fail on any error after running the target executable
+set -e
+
# Index the coverage data
# https://clang.llvm.org/docs/SourceBasedCodeCoverage.html#creating-coverage-reports
llvm-profdata merge -sparse "${PROFRAW_FILE}" -o "${PROFDATA_FILE}"