diff options
author | Sudarsana Babu Nagineni <sudarsana.babu@mapbox.com> | 2019-03-13 17:46:48 +0200 |
---|---|---|
committer | Sudarsana Babu Nagineni <sudarsana.babu@mapbox.com> | 2019-03-13 18:30:28 +0200 |
commit | b17c7e76fe8c2f93b9749a0499beb9138481055e (patch) | |
tree | 5fc095d621a65aae6ac3ed4fe26cbdfd8b488251 /scripts | |
parent | 44892f045259d553e47dd6fd5981db8ad6fe1700 (diff) | |
download | qtlocation-mapboxgl-b17c7e76fe8c2f93b9749a0499beb9138481055e.tar.gz |
[scripts] Fix local code coverage script
Fix the code cov script for coverage data collection
and report generation.
Diffstat (limited to 'scripts')
-rw-r--r--[-rwxr-xr-x] | scripts/collect-coverage.sh | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/scripts/collect-coverage.sh b/scripts/collect-coverage.sh index cd650975c6..07b7b56a83 100755..100644 --- a/scripts/collect-coverage.sh +++ b/scripts/collect-coverage.sh @@ -8,7 +8,7 @@ if [ -z ${WITH_COVERAGE} ] ; then exit 1 fi -directory=$1 +SOURCE_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/../"; pwd) function usage() { echo "Error: LCOV and genhtml are required for generating coverage reports." @@ -23,16 +23,19 @@ function usage() { command -v lcov >/dev/null 2>&1 || usage command -v genhtml >/dev/null 2>&1 || usage +# Build unit tests +make test + # Zero coverage counters lcov \ --quiet \ --zerocounters \ - --directory "${directory}" \ - --output-file "${directory}/coverage.info" \ + --directory "${SOURCE_DIR}" \ + --output-file "${SOURCE_DIR}/coverage.info" \ >/dev/null 2>&1 # Run all unit tests -make +make run-test # Collect coverage data and save it into coverage.info echo "Collecting coverage data..." @@ -40,15 +43,22 @@ lcov \ --quiet \ --capture \ --no-external \ - --directory "src/mbgl" \ - --directory "platform" \ - --directory "include/mbgl" \ - --directory "${directory}" \ - --base-directory "${directory}" \ - --output-file "${directory}/coverage.info" \ + --directory "${SOURCE_DIR}" \ + --output-file "${SOURCE_DIR}/coverage.info" \ + >/dev/null 2>&1 + +# Remove coverage data for unwanted files from a tracefile +lcov \ + --quiet \ + --remove "${SOURCE_DIR}/coverage.info" \ + "${SOURCE_DIR}/vendor/*" \ + "${SOURCE_DIR}/mason/*" \ + "${SOURCE_DIR}/test/*" \ + "/usr/include/*" \ + --output-file "${SOURCE_DIR}/total_coverage.info" \ >/dev/null 2>&1 -# Generate HTML report based on coverage.info +# Generate HTML report based on total_coverage.info echo "Generating HTML report..." genhtml \ --quiet \ @@ -61,8 +71,8 @@ genhtml \ --sort \ --demangle-cpp \ --prefix $(pwd -P) \ - --output-directory "${directory}/coverage" \ - "${directory}/coverage.info" \ + --output-directory "${SOURCE_DIR}/coverage" \ + "${SOURCE_DIR}/total_coverage.info" \ >/dev/null 2>&1 -echo "Coverage report is now available in ${directory}/coverage/index.html" +echo "Coverage report is now available in ${SOURCE_DIR}/coverage/index.html" |