Skip to content

genhtml interprets info file arg as value for --demangle-cpp option #432

@Krinkle

Description

@Krinkle

When using LCOV 1.14 (Debian 11 Bullseye), the following works as expected:

genhtml --output-directory ./coverage -t "$(basename "$PWD") test coverage report" --num-spaces 4 --demangle-cpp php-extension.info

When using LCOV 2.0-1 (Debian 13 Trixie), it fails as follows:

+ genhtml --output-directory ./coverage -t 'mediawiki-php-excimer test coverage report' --num-spaces 4 --demangle-cpp php-extension.info
genhtml: ERROR: could not find php-extension.info tool needed for --demangle-cpp

It seems the options parsing logic has changed such that it prefers interpreting the value after --demangle-cpp as the (optional) value of that option, as opposed to as the (required) tracefile argument.

Complete example

Input

$ docker run --rm -it --user root debian:13 

root@aa52dc050e1f:/# apt-get -qq update \
&& apt-get -yq install git php8.4-dev build-essential pkg-config libthai-dev liblua5.1-dev lcov \
&& git clone https://github.com/wikimedia/php-excimer.git \
&& cd php-excimer \
&& git checkout f0648e20378

root@aa52dc050e1f:/php-excimer# cat >run_coverage.sh <<'EOL'
#!/bin/bash
set -euxo pipefail
umask 002
REPORT_PATH=./coverage
INFO_FILE=php-extension.info
CFLAGS="-g -O0 --coverage -fprofile-arcs -ftest-coverage"
CXXFLAGS="$CFLAGS"
LDFLAGS="-lgcov"
EXTRA_LDFLAGS="-precious-files-regex \.gcno$"
phpize --version
phpize
CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS" LDFLAGS="$LDFLAGS" EXTRA_LDFLAGS="$EXTRA_LDFLAGS" ./configure
lcov --directory . --zerocounters
# Set NO_INTERACTION to skip "Do you want to save this report in a file? [Yn]" prompt
NO_INTERACTION=1 make test
lcov --directory . --capture --output-file $INFO_FILE
# There is usually no coverage in tests/* but exclude it just in case, ignore otherwise
lcov --remove $INFO_FILE "tests/*" "/usr/*" --ignore-errors unused --output-file $INFO_FILE
genhtml --output-directory $REPORT_PATH -t "${ZUUL_PROJECT:-$(basename "$PWD")} test coverage report" --num-spaces 4 --demangle-cpp $INFO_FILE
EOL

root@aa52dc050e1f:/php-excimer# chmod +x run_coverage.sh

root@aa52dc050e1f:/php-excimer# ./run_coverage.sh

Output

+ phpize
…
+ ./configure
…
+ lcov --directory . --zerocounters
…
+ make test
…
Tests passed    :    13 (100.0%) (100.0%)
…
+ lcov --directory . --capture --output-file php-extension.info
Capturing coverage data from .
geninfo cmd: '/usr/bin/geninfo . --toolname lcov --output-filename php-extension.info'
Found gcov version: 14.2.0
Using intermediate gcov format
Recording 'internal' directories:
	/php-excimer
	.
Writing temporary data to /tmp/geninfo_dat_ykV
Scanning . for .gcda files ...
Found 6 data files in .
using: chunkSize: 1, nchunks:6, intervalLength:0
lcov: WARNING: (inconsistent) /usr/include/php/20240924/Zend/zend_API.h:2225: unexecuted block on non-branch line with non-zero hit count.  Use "geninfo --rc geninfo_unexecuted_blocks=1 to set count to zero.
	(use "lcov --ignore-errors inconsistent,inconsistent ..." to suppress this warning)
Finished processing 6 GCDA files
Apply filtering..
Finished filter file processing
Finished .info-file creation
Summary coverage rate:
  source files: 16
  lines.......: 83.0% (1050 of 1265 lines)
  functions...: 87.0% (120 of 138 functions)
Message summary:
  1 warning message:
    inconsistent: 1
+ lcov --remove php-extension.info 'tests/*' '/usr/*' --ignore-errors unused --output-file php-extension.info
Excluding /usr/include/php/20240924/Zend/zend_API.h
Excluding /usr/include/php/20240924/Zend/zend_hash.h
Excluding /usr/include/php/20240924/Zend/zend_objects_API.h
Excluding /usr/include/php/20240924/Zend/zend_smart_str.h
Excluding /usr/include/php/20240924/Zend/zend_string.h
Excluding /usr/include/php/20240924/Zend/zend_types.h
Removed 6 files
Writing data to php-extension.info
Summary coverage rate:
  source files: 10
  lines.......: 82.6% (943 of 1141 lines)
  functions...: 87.0% (120 of 138 functions)
lcov: WARNING: (unused) 'exclude' pattern 'tests/*' is unused.
	(use "lcov --ignore-errors unused,unused ..." to suppress this warning)
Message summary:
  1 warning message:
    unused: 1
++ basename /php-excimer
+ genhtml --output-directory ./coverage -t 'php-excimer test coverage report' --num-spaces 4 --demangle-cpp php-extension.info
genhtml: ERROR: could not find php-extension.info tool needed for --demangle-cpp

See also:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions