|
9 | 9 |
|
10 | 10 | set -e |
11 | 11 |
|
| 12 | +clang_report=0 |
12 | 13 | nomalloc=0 |
13 | 14 |
|
14 | 15 | while [ $# -gt 0 ] ; do |
15 | 16 | case $1 in |
16 | 17 | nomalloc|-nomalloc) nomalloc=1;; |
| 18 | + clang|-clang|clang-report|-clang-report) clang_report=1;; |
17 | 19 | *) echo "Unknown option or test selector '$1'"; exit 1;; |
18 | 20 | esac |
19 | 21 | shift |
@@ -44,26 +46,40 @@ PROF_FILES="coverage-*.profraw" |
44 | 46 | llvm-profdata-$LLVM_VER merge -sparse $PROF_FILES -o coverage.profdata |
45 | 47 | echo "" |
46 | 48 |
|
47 | | -# Output LCOV-compatible output, for downstream tools |
48 | | -echo "== Generating LCOV report ==" |
49 | | -llvm-cov-$LLVM_VER export \ |
50 | | - -format=lcov \ |
51 | | - -instr-profile=coverage.profdata \ |
52 | | - ./pcre2test -object ./pcre2grep -object ./pcre2posix_test -object ./pcre2_jit_test \ |
53 | | - -sources ../src/ ./ \ |
54 | | - > ./coverage-lcov.info |
55 | | -echo "" |
| 49 | +if [ "$clang_report" -eq 1 ]; then |
| 50 | + echo "== Generating Clang coverage report ==" |
| 51 | + llvm-cov-$LLVM_VER show \ |
| 52 | + -format=html \ |
| 53 | + -show-line-counts-or-regions -show-branches=percent \ |
| 54 | + -instr-profile=coverage.profdata \ |
| 55 | + ./pcre2test -object ./pcre2grep -object ./pcre2posix_test -object ./pcre2_jit_test \ |
| 56 | + -sources ../src/ ./ \ |
| 57 | + -output-dir=coverage-html |
| 58 | + echo "" |
56 | 59 |
|
57 | | -# Filter out lines marked with "LCOV_EXCL_LINE" or "LCOV_EXCL_START"/"LCOV_EXCL_STOP" |
58 | | -echo "== Filtering LCOV report ==" |
59 | | -python3 ../maint/FilterCoverage.py ./coverage-lcov.info > ./coverage-lcov.filtered.info |
60 | | -mv ./coverage-lcov.filtered.info ./coverage-lcov.info |
61 | | -echo "" |
| 60 | +else |
| 61 | + # Output LCOV-compatible output, for downstream tools |
| 62 | + echo "== Generating LCOV report ==" |
| 63 | + llvm-cov-$LLVM_VER export \ |
| 64 | + -format=lcov \ |
| 65 | + -instr-profile=coverage.profdata \ |
| 66 | + ./pcre2test -object ./pcre2grep -object ./pcre2posix_test -object ./pcre2_jit_test \ |
| 67 | + -sources ../src/ ./ \ |
| 68 | + > ./coverage-lcov.info |
| 69 | + echo "" |
62 | 70 |
|
63 | | -# Use genhtml to generate an HTML report from the LCOV data |
64 | | -echo "== Generating HTML report ==" |
65 | | -mkdir -p coverage-html |
66 | | -genhtml \ |
67 | | - --highlight --branch-coverage --legend --title "PCRE2 code coverage report" --num-spaces 2 \ |
68 | | - -o coverage-html ./coverage-lcov.info |
69 | | -echo "" |
| 71 | + # Filter out lines marked with "LCOV_EXCL_LINE" or "LCOV_EXCL_START"/"LCOV_EXCL_STOP" |
| 72 | + echo "== Filtering LCOV report ==" |
| 73 | + python3 ../maint/FilterCoverage.py ./coverage-lcov.info > ./coverage-lcov.filtered.info |
| 74 | + mv ./coverage-lcov.filtered.info ./coverage-lcov.info |
| 75 | + echo "" |
| 76 | + |
| 77 | + # Use genhtml to generate an HTML report from the LCOV data |
| 78 | + echo "== Generating HTML report ==" |
| 79 | + mkdir -p coverage-html |
| 80 | + genhtml \ |
| 81 | + --highlight --branch-coverage --legend --title "PCRE2 code coverage report" --num-spaces 2 \ |
| 82 | + -o coverage-html ./coverage-lcov.info |
| 83 | + echo "" |
| 84 | + |
| 85 | +fi |
0 commit comments