Skip to content

Commit 2923924

Browse files
committed
[WIP] Azure: Publish code coverage results
See: https://externals.io/message/107113 Re: #4739 (comment)
1 parent d71f859 commit 2923924

File tree

5 files changed

+52
-20
lines changed

5 files changed

+52
-20
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,10 @@ tmp-php.ini
249249
# ------------------------------------------------------------------------------
250250
*.gcda
251251
*.gcno
252+
/gcovr_html/
252253
/lcov_html/
253254
/php_lcov.info
255+
/coverage.xml
254256

255257
# ------------------------------------------------------------------------------
256258
# Archives generated during the PHP release process

azure/apt.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,7 @@ steps:
3434
postgresql \
3535
postgresql-contrib \
3636
llvm \
37+
lcov \
38+
gcovr \
3739
${{ parameters.packages }}
3840
displayName: 'APT'

azure/configure.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,6 @@ steps:
5757
--with-mhash \
5858
--enable-werror \
5959
--with-config-file-path=/etc \
60-
--with-config-file-scan-dir=/etc/php.d
60+
--with-config-file-scan-dir=/etc/php.d \
61+
--enable-gcov
6162
displayName: 'Configure Build'

azure/test.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,23 @@ steps:
3131
failTaskOnFailedTests: true
3232
displayName: 'Export ${{ parameters.configurationName }} ${{ parameters.runTestsName }} Results'
3333
condition: or(succeeded(), failed())
34+
- script: |
35+
rm -rf coverage.xml | true
36+
gcovr -sr . -o coverage.xml --xml \
37+
-e '.*/ext/bcmath/libbcmath/.*' \
38+
-e '.*/ext/date/lib/.*' \
39+
-e '.*/ext/fileinfo/libmagic/.*' \
40+
-e '.*/ext/gd/libgd/.*' \
41+
-e '.*/ext/hash/sha3/.*' \
42+
-e '.*/ext/mbstring/libmbfl/.*' \
43+
-e '.*/ext/opcache/jit/libudis86/.*' \
44+
-e '.*/ext/pcre/pcre2lib/.*' \
45+
-e '.*/ext/xmlrpc/libxmlrpc/.*'
46+
displayName: 'Coverage ${{ parameters.configurationName }} ${{ parameters.runTestsName }}'
47+
condition: or(succeeded(), failed())
48+
- task: PublishCodeCoverageResults@1
49+
inputs:
50+
codeCoverageTool: 'Cobertura'
51+
summaryFileLocation: coverage.xml
52+
displayName: 'Export ${{ parameters.configurationName }} ${{ parameters.runTestsName }} Coverage'
53+
condition: or(succeeded(), failed())

build/Makefile.gcov

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,42 @@
11
#
2-
# LCOV
2+
# GCOV
33
#
44

5-
lcov: lcov-html
5+
GCOV_EXCLUDES = \
6+
'$(top_srcdir)/ext/bcmath/libbcmath/*' \
7+
'$(top_srcdir)/ext/date/lib/*' \
8+
'$(top_srcdir)/ext/fileinfo/libmagic/*' \
9+
'$(top_srcdir)/ext/gd/libgd/*' \
10+
'$(top_srcdir)/ext/hash/sha3/*' \
11+
'$(top_srcdir)/ext/mbstring/libmbfl/*' \
12+
'$(top_srcdir)/ext/opcache/jit/libudis86/*' \
13+
'$(top_srcdir)/ext/pcre/pcre2lib/*' \
14+
'$(top_srcdir)/ext/xmlrpc/libxmlrpc/*'
615

7-
lcov-test: lcov-clean-data test
8-
9-
php_lcov.info: lcov-test
16+
php_lcov.info: test
1017
@echo "Generating lcov data for $@"
11-
@$(LTP) --capture --no-external --directory . --output-file $@
18+
$(LTP) --capture --no-external --directory . --output-file $@
1219
@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 $@
20+
$(LTP) --output-file $@ --remove $@ '*/<stdout>' $(GCOV_EXCLUDES)
2521

2622
lcov-html: php_lcov.info
2723
@echo "Generating lcov HTML"
28-
@$(LTP_GENHTML) --legend --output-directory lcov_html/ --title "PHP Code Coverage" php_lcov.info
24+
$(LTP_GENHTML) --legend --output-directory lcov_html/ --title "PHP Code Coverage" php_lcov.info
2925

3026
lcov-clean:
3127
rm -f php_lcov.info
3228
rm -rf lcov_html/
3329

3430
lcov-clean-data:
3531
@find . -name \*.gcda -o -name \*.da -o -name \*.bbg? | xargs rm -f
32+
33+
gcovr-html: test
34+
@echo "Generating gcovr HTML"
35+
@rm -rf gcovr_html/
36+
@mkdir gcovr_html
37+
gcovr -sr . -o gcovr_html/index.html --html --html-details $(foreach lib, $(GCOV_EXCLUDES), -e $(lib))
38+
39+
gcovr-xml: test
40+
@echo "Generating gcovr XML"
41+
@rm -f coverage.xml
42+
gcovr -sr . -o coverage.xml --xml $(foreach lib, $(GCOV_EXCLUDES), -e $(lib))

0 commit comments

Comments
 (0)