sebastianbergmann / phpcov

TextUI frontend for php-code-coverage
BSD 3-Clause "New" or "Revised" License
223 stars 58 forks source link

Complete work on #126 #127

Closed Slamdunk closed 1 year ago

Slamdunk commented 1 year ago

I've seen that https://github.com/sebastianbergmann/phpcov/commit/fb1e9af6e510bb0720b086f5e61c3cbbdf589720 wiped out coverage informations within the two *.cov committed files.

I've regenerated them with:

XDEBUG_MODE=coverage \
    php8.1 vendor/bin/phpunit \
    --configuration tests/fixture/example/phpunit.xml \
    --filter testGreetsWorld \
    --coverage-php tests/fixture/example/coverage/testGreetsWorld.cov

XDEBUG_MODE=coverage \
    php8.1 vendor/bin/phpunit \
    --configuration tests/fixture/example/phpunit.xml \
    --filter testGreetsWithName \
    --coverage-php tests/fixture/example/coverage/testGreetsWithName.cov

And now the tests pass on both PHP 8.1 and PHP 8.2 for PHPUnit 10.0.7:

$ XDEBUG_MODE=coverage php8.1 vendor/bin/phpunit
PHPUnit 10.0.7 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.1.14
Configuration: /usr/local/src/phpcov/phpunit.xml

....................                                              20 / 20 (100%)

Time: 00:00.754, Memory: 6.00 MB

OK (20 tests, 20 assertions)

$ XDEBUG_MODE=coverage php8.2 vendor/bin/phpunit
PHPUnit 10.0.7 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.2.2
Configuration: /usr/local/src/phpcov/phpunit.xml

....................                                              20 / 20 (100%)

Time: 00:00.786, Memory: 6.00 MB

OK (20 tests, 20 assertions)
sebastianbergmann commented 1 year ago

You are amazing! Thank you, Filippo!

sebastianbergmann commented 1 year ago

I updated those two files using the update-fixture target. Somehow I did not have a code coverage driver available when I did, I suppose. The target needs to be updated so that this does not happen again.

sebastianbergmann commented 1 year ago

The tests fail for me:

$ ./vendor/bin/phpunit
PHPUnit 10.0-dev by Sebastian Bergmann and contributors.

Runtime:       PHP 8.2.2
Configuration: /usr/local/src/phpcov/phpunit.xml

F...................                                              20 / 20 (100%)

Time: 00:01.405, Memory: 6.00 MB

There was 1 failure:

1) /usr/local/src/phpcov/tests/end-to-end/execute/valid-script-argument-with-cli-include-with-text-report.phpt
Failed asserting that string matches format description.
--- Expected
+++ Actual
@@ @@
  Summary:              
   Classes:        (0/0)
   Methods:        (0/0)
-  Lines:   50.00% (1/2)
+  Lines:          (0/0)

/usr/local/src/phpcov/tests/end-to-end/execute/valid-script-argument-with-cli-include-with-text-report.phpt:48

FAILURES!
Tests: 20, Assertions: 20, Failures: 1.
Slamdunk commented 1 year ago

That happens when you have PCOV enabled. In order to get the test pass I had to disable PCOV and enable xDebug.

Try:

XDEBUG_MODE=coverage php8.1 -d pcov.enabled=0 vendor/bin/phpunit
sebastianbergmann commented 1 year ago

Ah, hm. That is not ideal, but good enough for now, I guess. Thanks! I will keep this in mind for #128.