Skip to content

Commit 9cc1bf5

Browse files
gerardrochenikic
authored andcommitted
Fix GCOV not working for PHP-7.4 and master branches
Code coverage reports (`make lcov`), since commit eef8522 (7.4 branch), generates incorrect coverage and emits warnings. Simplifying the Makefile.gcov file has the side-effect of resolving the issue. Processing sapi/cli/php_http_parser.gcda php-src/lcov_data/sapi/cli/php_http_parser.gcda:stamp mismatch with notes file geninfo: WARNING: gcov did not create any files for php-src/lcov_data/sapi/cli/php_http_parser.gcda! ... Processing ext/mbstring/mb_gpc.gcda php-src/lcov_data/ext/mbstring/mb_gpc.gcda:stamp mismatch with notes file geninfo: WARNING: gcov did not create any files for php-src/lcov_data/ext/mbstring/mb_gpc.gcda! Closes: https://bugs.php.net/bug.php?id=52718. See also: https://bugs.php.net/bug.php?id=78288.
1 parent 3205ebe commit 9cc1bf5

File tree

2 files changed

+15
-59
lines changed

2 files changed

+15
-59
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,6 @@ tmp-php.ini
249249
# ------------------------------------------------------------------------------
250250
*.gcda
251251
*.gcno
252-
/lcov_data/
253252
/lcov_html/
254253
/php_lcov.info
255254

build/Makefile.gcov

Lines changed: 15 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -2,76 +2,33 @@
22
# LCOV
33
#
44

5-
LCOV_INCLUDE="."
6-
75
lcov: lcov-html
86

97
lcov-test: lcov-clean-data test
108

119
php_lcov.info: lcov-test
12-
@echo "Generating data for $@"
13-
@rm -rf lcov_data/
14-
@$(mkinstalldirs) lcov_data/
15-
@echo
16-
-@files=`find . -name \*.gcda -o -name \*.gcno -o -name \*.da -o -name \*.c -o -name \*.h | sed -e 's/^\.\///' | sed -e 's/\.gcda//g' -e 's/\.gcno//g' -e 's/\.da//g' | $(EGREP) $(LCOV_INCLUDE) | sed -e 's/.libs/zzzz/g' | sort | sed -e 's/zzzz/.libs/g' | uniq` ;\
17-
for x in $$files; do \
18-
echo -n . ;\
19-
y=`echo $$x | sed -e 's!\.libs/!!'`; \
20-
dir=lcov_data/`dirname $$x`; \
21-
test -d "$$dir" || $(mkinstalldirs) "$$dir"; \
22-
if test -f "$(top_srcdir)/$$y.c"; then \
23-
ln -f -s $(top_srcdir)/$$y.c lcov_data/$$y.c; \
24-
fi; \
25-
if test -f "$(top_srcdir)/$$y.h"; then \
26-
ln -f -s $(top_srcdir)/$$y.h lcov_data/$$y.h; \
27-
fi; \
28-
if test -f "$(top_srcdir)/$$y.re"; then \
29-
ln -f -s $(top_srcdir)/$$y.re lcov_data/$$y.re; \
30-
fi; \
31-
if test -f "$(top_srcdir)/$$y.y"; then \
32-
ln -f -s $(top_srcdir)/$$y.y lcov_data/$$y.y; \
33-
fi; \
34-
if test -f "$(top_srcdir)/$$y.l"; then \
35-
ln -f -s $(top_srcdir)/$$y.l lcov_data/$$y.l; \
36-
fi; \
37-
if test -f "$(top_srcdir)/$$y"; then \
38-
ln -f -s $(top_srcdir)/$$y lcov_data/$$y; \
39-
fi; \
40-
if test -f "$(top_builddir)/$$y.c"; then \
41-
ln -f -s $(top_builddir)/$$y.c lcov_data/$$y.c; \
42-
fi; \
43-
if test -f "$$x.gcno"; then \
44-
cp $$x.gcno lcov_data/$$y.gcno ; \
45-
fi; \
46-
if test -f "$$x.gcda"; then \
47-
cp $$x.gcda lcov_data/$$y.gcda ; \
48-
fi; \
49-
if test -f "$$x.da"; then \
50-
cp $$x.da lcov_data/$$y.da ; \
51-
fi; \
52-
if test -f "$$x.bb"; then \
53-
cp $$x.bb lcov_data/$$y.bb ; \
54-
fi; \
55-
if test -f "$$x.bbg"; then \
56-
cp $$x.bbg lcov_data/$$y.bbg ; \
57-
fi; \
58-
done; \
59-
for dir in ext/date/lib ext/fileinfo/libmagic ext/gd/libgd ext/pcre/pcre2lib; do \
60-
if test -d lcov_data/$$dir; then \
61-
rm -rf lcov_data/$$dir ; \
62-
fi; \
63-
done
64-
@echo
65-
@echo "Generating $@"
66-
@$(LTP) --directory lcov_data/ --capture --base-directory=lcov_data --output-file $@
10+
@echo "Generating lcov data for $@"
11+
@$(LTP) --capture --no-external --directory . --output-file $@
12+
@echo "Stripping bundled libraries from $@"
13+
@$(LTP) --remove $@ \
14+
'*/<stdout>' \
15+
'$(top_srcdir)/ext/bcmath/libbcmath/*' \
16+
'$(top_srcdir)/ext/date/lib/*' \
17+
'$(top_srcdir)/ext/fileinfo/libmagic/*' \
18+
'$(top_srcdir)/ext/gd/libgd/*' \
19+
'$(top_srcdir)/ext/hash/sha3/*' \
20+
'$(top_srcdir)/ext/mbstring/libmbfl/*' \
21+
'$(top_srcdir)/ext/opcache/jit/libudis86/*' \
22+
'$(top_srcdir)/ext/pcre/pcre2lib/*' \
23+
'$(top_srcdir)/ext/xmlrpc/libxmlrpc/*' \
24+
--output-file $@
6725

6826
lcov-html: php_lcov.info
6927
@echo "Generating lcov HTML"
7028
@$(LTP_GENHTML) --legend --output-directory lcov_html/ --title "PHP Code Coverage" php_lcov.info
7129

7230
lcov-clean:
7331
rm -f php_lcov.info
74-
rm -rf lcov_data/
7532
rm -rf lcov_html/
7633

7734
lcov-clean-data:

0 commit comments

Comments
 (0)