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

The command line argument "--whitelist" has no effect with phpunit 6.4.3. #2844

Closed
damyon opened this issue Nov 8, 2017 · 4 comments
Closed
Labels
type/bug Something is broken

Comments

@damyon
Copy link

damyon commented Nov 8, 2017

Q A
PHPUnit version 6.4.3
PHP version 7.1.11
Installation Method PHAR

The command line argument "--whitelist" has no effect with phpunit 6.4.3. The exact same command line does work with phpunit 5.5.7.

I am testing code coverage for Moodle (https://github.com/moodle/moodle) with phpunit. My command line is:
vendor/bin/phpunit --coverage-text --whitelist blocks/online_users/ blocks/online_users/tests/online_users_test.php

I get

Error: No whitelist is configured, no code coverage will be generated.

in the output, and no code coverage information is printed with phpunit 6.4.

@sebastianbergmann
Copy link
Owner

I cannot reproduce this:

$ ll src 
total 4.0K
-rw-rw-r--. 1 sb sb 671 Nov  7 08:29 Email.php
$ ll tests 
total 4.0K
-rw-rw-r--. 1 sb sb 678 Nov  7 11:14 EmailTest.php
$ ./vendor/bin/phpunit --whitelist src --coverage-text tests
PHPUnit 6.4.3 by Sebastian Bergmann and contributors.

...                                                                 3 / 3 (100%)

Time: 48 ms, Memory: 4.00MB

OK (3 tests, 3 assertions)


Code Coverage Report:   
  2017-11-08 04:43:56   
                        
 Summary:               
  Classes: 100.00% (1/1)
  Methods: 100.00% (4/4)
  Lines:   100.00% (9/9)

Email
  Methods: 100.00% ( 4/ 4)   Lines: 100.00% (  9/  9)

@damyon
Copy link
Author

damyon commented Nov 8, 2017

Thanks for testing and responding so quickly. I stripped down my use case to a bare example like yours, and the presence of a simple phpunit.xml file is enough to trigger the problem.

My phpunit file is attached (renamed to phpunit.xml.txt so I could upload it here).

phpunit.xml.txt

@scara
Copy link

scara commented Nov 8, 2017

Hi @sebastianbergmann,
if you want the exact test case and you've a linux docker env:

  1. Get the scripts to setup the docker environment:
git clone https://github.com/moodlehq/moodle-docker
  1. PHPUnit 5.5.*:
   git clone https://github.com/moodle/moodle moodle-phpu55 \
&& cd moodle-phpu55 \
&& git checkout 159b4e5d8c773fc1c71cb97e728d05f4cbb9d49e \
&& export MOODLE_DOCKER_WWWROOT=$(pwd) \
&& export MOODLE_DOCKER_DB=pgsql \
&& cd ../moodle-docker \
&& cp config.docker-template.php $MOODLE_DOCKER_WWWROOT/config.php \
&& bin/moodle-docker-compose up -d \
&& sleep 5 \
&& bin/moodle-docker-compose exec webserver php admin/tool/phpunit/cli/init.php \
&& bin/moodle-docker-compose exec webserver vendor/bin/phpunit --coverage-text --whitelist blocks/online_users/ blocks/online_users/tests/online_users_test.php \
&& bin/moodle-docker-compose down \
&& cd ..
  1. PHPUnit 6.4.*:
   git clone git://git.moodle.org/integration.git moodle-phpu64 \
&& cd moodle-phpu64 \
&& git checkout c9f995872f523864cb4bcaa6c4d047379ddb402b \
&& export MOODLE_DOCKER_WWWROOT=$(pwd) \
&& cd ../moodle-docker \
&& cp config.docker-template.php $MOODLE_DOCKER_WWWROOT/config.php \
&& bin/moodle-docker-compose up -d \
&& sleep 5 \
&& bin/moodle-docker-compose exec webserver php admin/tool/phpunit/cli/init.php \
&& && bin/moodle-docker-compose exec webserver vendor/bin/phpunit --coverage-text --whitelist blocks/online_users/ blocks/online_users/tests/online_users_test.php \
&& bin/moodle-docker-compose down \
&& cd ..

(quickly wrote, hoping no script issues)

HTH,
Matteo

@sebastianbergmann
Copy link
Owner

I am now able reproduce the issue with PHPUnit >= 6.1. The issue is not present in PHPUnit 6.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something is broken
Projects
None yet
Development

No branches or pull requests

3 participants