Skip to content

Commit e6ae87e

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

File tree

5 files changed

+54
-9
lines changed

5 files changed

+54
-9
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: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ steps:
1414
export SKIP_IO_CAPTURE_TESTS=1
1515
export MSAN_SYMBOLIZER_PATH=/usr/lib/llvm-3.8/bin/llvm-symbolizer
1616
rm -rf junit.xml | true
17+
which php
18+
php -i
1719
php run-tests.php -P -q \
1820
-j$(/usr/bin/nproc) \
1921
-g FAIL,XFAIL,BORK,WARN,LEAK,XLEAK,SKIP \
@@ -31,3 +33,23 @@ steps:
3133
failTaskOnFailedTests: true
3234
displayName: 'Export ${{ parameters.configurationName }} ${{ parameters.runTestsName }} Results'
3335
condition: or(succeeded(), failed())
36+
- script: |
37+
gcovr -sr . -o coverage.xml --xml \
38+
-e 'ext/bcmath/libbcmath/*' \
39+
-e 'ext/date/lib/*' \
40+
-e 'ext/fileinfo/libmagic/*' \
41+
-e 'ext/gd/libgd/*' \
42+
-e 'ext/hash/sha3/*' \
43+
-e 'ext/mbstring/libmbfl/*' \
44+
-e 'ext/opcache/jit/libudis86/*' \
45+
-e 'ext/pcre/pcre2lib/*' \
46+
-e 'ext/xmlrpc/libxmlrpc/*'
47+
ls -Al
48+
displayName: 'Coverage ${{ parameters.configurationName }} ${{ parameters.runTestsName }}'
49+
condition: or(succeeded(), failed())
50+
- task: PublishCodeCoverageResults@1
51+
inputs:
52+
codeCoverageTool: 'Cobertura'
53+
summaryFileLocation: coverage.xml
54+
displayName: 'Export ${{ parameters.configurationName }} ${{ parameters.runTestsName }} Coverage'
55+
condition: or(succeeded(), failed())

build/Makefile.gcov

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
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 $@ \
20+
$(LTP) --remove $@ \
1421
'*/<stdout>' \
1522
'$(top_srcdir)/ext/bcmath/libbcmath/*' \
1623
'$(top_srcdir)/ext/date/lib/*' \
@@ -25,11 +32,22 @@ php_lcov.info: lcov-test
2532

2633
lcov-html: php_lcov.info
2734
@echo "Generating lcov HTML"
28-
@$(LTP_GENHTML) --legend --output-directory lcov_html/ --title "PHP Code Coverage" php_lcov.info
35+
$(LTP_GENHTML) --legend --output-directory lcov_html/ --title "PHP Code Coverage" php_lcov.info
2936

3037
lcov-clean:
3138
rm -f php_lcov.info
3239
rm -rf lcov_html/
3340

3441
lcov-clean-data:
3542
@find . -name \*.gcda -o -name \*.da -o -name \*.bbg? | xargs rm -f
43+
44+
gcovr-html: test
45+
@echo "Generating gcovr HTML"
46+
@rm -rf gcovr_html/
47+
@mkdir gcovr_html
48+
gcovr -sr . -o gcovr_html/index.html --html --html-details $(foreach lib, $(GCOV_EXCLUDES), -e $(lib))
49+
50+
gcovr-xml: test
51+
@echo "Generating gcovr XML"
52+
@rm -f coverage.xml
53+
gcovr -sr . -o coverage.xml --xml $(foreach lib, $(GCOV_EXCLUDES), -e $(lib))

0 commit comments

Comments
 (0)