Gilad Arnold | ab3bb45 | 2012-05-22 09:08:12 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
| 4 | # Use of this source code is governed by a BSD-style license that can be |
| 5 | # found in the LICENSE file. |
| 6 | |
| 7 | # Builds, runs unit tests, then collects and processes coverage data for update |
| 8 | # engine binaries. In the case where lcov/genhtml are missing, it will just |
| 9 | # build and run the unit tests. |
| 10 | |
| 11 | DO_COVERAGE=$(which lcov genhtml > /dev/null 2>&1 && echo 1) |
| 12 | |
| 13 | set -ex |
| 14 | |
| 15 | ./build debug=1 |
| 16 | if [[ $DO_COVERAGE ]]; then |
| 17 | lcov --directory . --zerocounters |
| 18 | fi |
| 19 | ./run_unittests |
| 20 | if [[ $DO_COVERAGE ]]; then |
| 21 | lcov --directory . --capture --output-file app.info |
| 22 | |
| 23 | # We try to use genhtml with --no-function-coverage, if it is supported. The |
| 24 | # problem w/ function coverage is that every template instantiation of a |
| 25 | # method counts as a different method, so if we instantiate a method twice, |
| 26 | # once for testing and once for prod, the method is tested, but it shows only |
| 27 | # 50% function coverage b/c it thinks we didn't test the prod version. |
| 28 | GENHTML_NO_FUNC_COV=$(genhtml --help | grep -q function-coverage && |
| 29 | echo --no-function-coverage) |
| 30 | genhtml $GENHTML_NO_FUNC_CONV --output-directory html app.info |
| 31 | ./local_coverage_rate |
| 32 | fi |