xref: /aosp_15_r20/external/jazzer-api/bazel/coverage/coverage.sh (revision 33edd6723662ea34453766bfdca85dbfdd5342b8)
1*33edd672SMark#!/usr/bin/env sh
2*33edd672SMark# Copyright 2022 Code Intelligence GmbH
3*33edd672SMark#
4*33edd672SMark# Licensed under the Apache License, Version 2.0 (the "License");
5*33edd672SMark# you may not use this file except in compliance with the License.
6*33edd672SMark# You may obtain a copy of the License at
7*33edd672SMark#
8*33edd672SMark#      http://www.apache.org/licenses/LICENSE-2.0
9*33edd672SMark#
10*33edd672SMark# Unless required by applicable law or agreed to in writing, software
11*33edd672SMark# distributed under the License is distributed on an "AS IS" BASIS,
12*33edd672SMark# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*33edd672SMark# See the License for the specific language governing permissions and
14*33edd672SMark# limitations under the License.
15*33edd672SMark
16*33edd672SMark
17*33edd672SMark# Use just like `bazel test` to generate and open an HTML coverage report.
18*33edd672SMark# Requires a local installation of Perl.
19*33edd672SMark
20*33edd672SMarkRUNFILES_ROOT=$PWD
21*33edd672SMarkcd "$BUILD_WORKSPACE_DIRECTORY" || exit 1
22*33edd672SMarkif ! bazel coverage "${@:-//...}";
23*33edd672SMarkthen
24*33edd672SMark  exit $?
25*33edd672SMarkfi
26*33edd672SMark"$RUNFILES_ROOT"/../genhtml/file/genhtml -o coverage \
27*33edd672SMark  --prefix "$PWD" \
28*33edd672SMark  --title "bazel coverage ${*:-//...}" \
29*33edd672SMark  bazel-out/_coverage/_coverage_report.dat
30*33edd672SMarkxdg-open coverage/index.html > /dev/null 2>&1
31