Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XML report issues in PHP 8.1 #880

Closed
veewee opened this issue Nov 16, 2021 · 1 comment
Closed

XML report issues in PHP 8.1 #880

veewee opened this issue Nov 16, 2021 · 1 comment

Comments

@veewee
Copy link

veewee commented Nov 16, 2021

Q A
PHPUnit version 9.5.10
PHP version PHP 8.1.0-dev (cli) (built: Nov 15 2021 00:34:49)
Installation Method PHAR

Summary

While making my packages PHP 81 ready, I bumped into this issue:

When running infection on php 8.1 I noticed some uncovered mutants.
It turns out that the XML coverage report is missing some information and therefore cannot run the covering tests.
These lines are available on PHP 8.0.
I'm using pcov 1.0.9 on both versions for coverage.

Not sure this is the right place to report this issue. It might have to do with another package. Feel free to point me elsewhere!

Current behavior

On PHP 8.0 these lines are available for file ".phpunit.cache/xml/Dom/Traverser/Visitor/SortAttributes.php.xml"

            <line no="26">
                <token name="T_WHITESPACE">                    </token>
                <token name="T_STRING">append</token>
                <token name="T_OPEN_BRACKET">(</token>
                <token name="T_VARIABLE">$attr</token>
                <token name="T_CLOSE_BRACKET">)</token>
                <token name="T_OPEN_BRACKET">(</token>
                <token name="T_VARIABLE">$node</token>
                <token name="T_CLOSE_BRACKET">)</token>
                <token name="T_SEMICOLON">;</token>
            </line>

On PHP 8.1, it jumps from line 25 to 27.
Line 26 is missing from the XML, making infection not able to determine the tests that cover that line.

How to reproduce

Install

git clone https://github.com/veewee/xml.git
git checkout php81-support
composer install
phive install

Run with both PHP versions:

./tools/phpunit.phar --coverage-xml .phpunit.cache/xml

Compare:

.phpunit.cache/xml/Dom/Traverser/Visitor/SortAttributes.php.xml

other files that are different and cause issues:

  • .phpunit.cache/xml/Reader/Reader.php.xml
  • .phpunit.cache/xml/Writer/Writer.php.xml

Expected behavior

Both files should be the same and not missing the line.

@sebastianbergmann sebastianbergmann transferred this issue from sebastianbergmann/phpunit Nov 16, 2021
@sebastianbergmann
Copy link
Owner

This does not look like an issue in this library. My best guess is that PHP 8.1 generates different bytecode compared to PHP 8.0 and therefore PCOV reports different line coverage.

If at all, this would be an issue to report for PCOV. What do you think, @krakjoe?

And for @derickr it might be interesting to know whether Xdebug reports different code coverage using PHP 8.1 compared to PHP 8.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants