Skip to content

Commit 38673b3

Browse files
authored
Tweak some test coverage inclusions
1 parent ea16201 commit 38673b3

File tree

5 files changed

+25
-11
lines changed

5 files changed

+25
-11
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,8 @@ jobs:
539539
submodules: true
540540

541541
- name: Configure
542+
# We use DEBUG=OFF here in order to suppress the coverage misses due to
543+
# assertions, which obviously always pass.
542544
run: CC="clang -fprofile-instr-generate -fcoverage-mapping" cmake $CMAKE_FLAGS -DCMAKE_BUILD_TYPE=Debug -DPCRE2_DEBUG=OFF -DPCRE2_SUPPORT_JIT=ON -DPCRE2_BUILD_PCRE2_16=ON -DPCRE2_BUILD_PCRE2_32=ON -DPCRE2_SUPPORT_LIBZ=ON -DPCRE2_SUPPORT_LIBBZ2=ON -DPCRE2_SUPPORT_LIBEDIT=ON -DPCRE2_SUPPORT_LIBREADLINE=OFF -B build
543545

544546
- name: Build

maint/FilterCoverage.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,17 @@ def scan_exclusions(srcpath):
2727
continue
2828
if in_block:
2929
excl.add(i)
30+
31+
# If line matches '^\s*#(if|endif|else|elif)\b', exclude it.
32+
# For some reason, Clang likes to output coverage for these lines,
33+
# even though they have no executable code.
34+
if re.match(r'^\s*#(if|endif|else|elif|ifdef|ifndef)\b', line):
35+
excl.add(i)
36+
37+
# Similarly, Clang seems to generate DA entries for "}" lines inside
38+
# switch statements. Exclude these too.
39+
if re.match(r'^\s*}\s*(/\*.*?\*/)?$', line):
40+
excl.add(i)
3041
return excl
3142

3243
DA_RE = re.compile(r'^\s*DA:(\d+),(\d+)(,.*)?\s*$')

src/pcre2_context.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -502,10 +502,7 @@ return 0;
502502
}
503503

504504
/* These functions became obsolete at release 10.30. The first is kept as a
505-
synonym for backwards compatibility. The second now does nothing. Exclude both
506-
from coverage reports. */
507-
508-
/* LCOV_EXCL_START */
505+
synonym for backwards compatibility. The second now does nothing. */
509506

510507
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
511508
pcre2_set_recursion_limit(pcre2_match_context *mcontext, uint32_t limit)
@@ -525,8 +522,6 @@ pcre2_set_recursion_memory_management(pcre2_match_context *mcontext,
525522
return 0;
526523
}
527524

528-
/* LCOV_EXCL_STOP */
529-
530525

531526
/* ------------ Convert context ------------ */
532527

src/pcre2_util.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ side-effects. */
7171
} while(0)
7272
#endif
7373

74+
/* LCOV_EXCL_START */
75+
7476
/* PCRE2_UNREACHABLE() can be used to mark locations on the code that
7577
shouldn't be reached. In non debug builds is defined as a hint for
7678
the compiler to eliminate any code after it, so it is useful also for
@@ -107,8 +109,16 @@ the reason and the actions that should be taken if it ever triggers. */
107109

108110
#define PCRE2_DEBUG_UNREACHABLE() PCRE2_UNREACHABLE()
109111

112+
/* LCOV_EXCL_STOP */
113+
110114
#endif /* PCRE2_DEBUG */
111115

116+
#ifndef PCRE2_ASSERT
117+
#define PCRE2_ASSERT(x) do {} while(0)
118+
#endif
119+
120+
/* LCOV_EXCL_START */
121+
112122
#ifndef PCRE2_DEBUG_UNREACHABLE
113123
#define PCRE2_DEBUG_UNREACHABLE() do {} while(0)
114124
#endif
@@ -123,9 +133,7 @@ the reason and the actions that should be taken if it ever triggers. */
123133
#endif
124134
#endif /* !PCRE2_UNREACHABLE */
125135

126-
#ifndef PCRE2_ASSERT
127-
#define PCRE2_ASSERT(x) do {} while(0)
128-
#endif
136+
/* LCOV_EXCL_STOP */
129137

130138
/* We define this fallthrough macro for suppressing -Wimplicit-fallthrough warnings.
131139
Clang only allows this via an attribute, whereas other compilers (eg. GCC) match attributes

src/pcre2posix.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,10 +331,8 @@ preg->re_erroffset = (size_t)(-1); /* No meaning after successful compile */
331331

332332
if (preg->re_match_data == NULL)
333333
{
334-
/* LCOV_EXCL_START */
335334
pcre2_code_free(preg->re_pcre2_code);
336335
return REG_ESPACE;
337-
/* LCOV_EXCL_STOP */
338336
}
339337

340338
return 0;

0 commit comments

Comments
 (0)