Skip to content

Commit 9b541b1

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

File tree

5 files changed

+56
-5
lines changed

5 files changed

+56
-5
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ tmp-php.ini
249249
# ------------------------------------------------------------------------------
250250
*.gcda
251251
*.gcno
252+
/gcovr/
252253
/lcov_html/
253254
/php_lcov.info
254255

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: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,18 @@ steps:
2121
--show-slow 1000 \
2222
--set-timeout 120 \
2323
${{ parameters.runTestsParameters }}
24+
rm -rf gcovr/
25+
mkdir -p gcovr | true
26+
gcovr -sr . -o gcovr/coverage.xml --xml \
27+
-e 'ext/bcmath/libbcmath/*' \
28+
-e 'ext/date/lib/*' \
29+
-e 'ext/fileinfo/libmagic/*' \
30+
-e 'ext/gd/libgd/*' \
31+
-e 'ext/hash/sha3/*' \
32+
-e 'ext/mbstring/libmbfl/*' \
33+
-e 'ext/opcache/jit/libudis86/*' \
34+
-e 'ext/pcre/pcre2lib/*' \
35+
-e 'ext/xmlrpc/libxmlrpc/*'
2436
displayName: 'Test ${{ parameters.configurationName }} ${{ parameters.runTestsName }}'
2537
condition: or(succeeded(), failed())
2638
- task: PublishTestResults@2
@@ -31,3 +43,10 @@ steps:
3143
failTaskOnFailedTests: true
3244
displayName: 'Export ${{ parameters.configurationName }} ${{ parameters.runTestsName }} Results'
3345
condition: or(succeeded(), failed())
46+
- task: PublishCodeCoverageResults@1
47+
inputs:
48+
codeCoverageTool: 'cobertura'
49+
summaryFileLocation: gcovr/coverage.xml
50+
failIfCoverageEmpty: true
51+
displayName: 'Export ${{ parameters.configurationName }} ${{ parameters.runTestsName }} Coverage'
52+
condition: or(succeeded(), failed())

build/Makefile.gcov

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,27 @@
11
#
2-
# LCOV
2+
# GCOV
33
#
44

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/*'
15+
516
lcov: lcov-html
617

718
lcov-test: lcov-clean-data test
819

920
php_lcov.info: lcov-test
1021
@echo "Generating lcov data for $@"
11-
@$(LTP) --capture --no-external --directory . --output-file $@
22+
$(LTP) --capture --no-external --directory . --output-file $@
1223
@echo "Stripping bundled libraries from $@"
13-
@$(LTP) --remove $@ \
24+
$(LTP) --remove $@ \
1425
'*/<stdout>' \
1526
'$(top_srcdir)/ext/bcmath/libbcmath/*' \
1627
'$(top_srcdir)/ext/date/lib/*' \
@@ -25,11 +36,28 @@ php_lcov.info: lcov-test
2536

2637
lcov-html: php_lcov.info
2738
@echo "Generating lcov HTML"
28-
@$(LTP_GENHTML) --legend --output-directory lcov_html/ --title "PHP Code Coverage" php_lcov.info
39+
$(LTP_GENHTML) --legend --output-directory lcov_html/ --title "PHP Code Coverage" php_lcov.info
2940

3041
lcov-clean:
3142
rm -f php_lcov.info
3243
rm -rf lcov_html/
3344

3445
lcov-clean-data:
3546
@find . -name \*.gcda -o -name \*.da -o -name \*.bbg? | xargs rm -f
47+
48+
gcovr: gcovr-html
49+
50+
gcovr-test: gcovr-clean test
51+
52+
gcovr-html: gcovr-test
53+
@echo "Generating gcovr HTML"
54+
@mkdir -p gcovr
55+
gcovr -sr . -o gcovr/index.html --html --html-details $(foreach lib, $(GCOV_EXCLUDES), -e $(lib))
56+
57+
gcovr-xml: gcovr-test
58+
@echo "Generating gcovr XML"
59+
@mkdir -p gcovr
60+
gcovr -sr . -o gcovr/coverage.xml --xml $(foreach lib, $(GCOV_EXCLUDES), -e $(lib))
61+
62+
gcovr-clean:
63+
rm -rf gcovr/

0 commit comments

Comments
 (0)