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

PHPUnit 3.6.0: Undefined index: addUncoveredFilesFromWhitelist in /usr/share/php/PHPUnit/TextUI/TestRunner.php on line 254 #391

Closed
tmysik opened this issue Nov 2, 2011 · 14 comments

Comments

@tmysik
Copy link

tmysik commented Nov 2, 2011

Try to run test with code-coverage enabled. Result:

PHP Notice: Undefined index: addUncoveredFilesFromWhitelist in /usr/share/php/PHPUnit/TextUI/TestRunner.php on line 254
PHP Stack trace:
PHP 1. {main}() /usr/bin/phpunit:0
PHP 2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:46
PHP 3. PHPUnit_TextUI_Command->run() /usr/share/php/PHPUnit/TextUI/Command.php:126
PHP 4. PHPUnit_TextUI_TestRunner->doRun() /usr/share/php/PHPUnit/TextUI/Command.php:188
PHP Fatal error: Uncaught exception 'InvalidArgumentException' in /usr/share/php/PHP/CodeCoverage.php:386
Stack trace:
#0 /usr/share/php/PHPUnit/TextUI/TestRunner.php(255): PHP_CodeCoverage->setProcessUncoveredFilesFromWhitelist(NULL)
#1 /usr/share/php/PHPUnit/TextUI/Command.php(188): PHPUnit_TextUI_TestRunner->doRun(Object(NetBeansSuite), Array)
#2 /usr/share/php/PHPUnit/TextUI/Command.php(126): PHPUnit_TextUI_Command->run(Array, true)
#3 /usr/bin/phpunit(46): PHPUnit_TextUI_Command::main()
#4 {main}

thrown in /usr/share/php/PHP/CodeCoverage.php on line 386
PHPUnit 3.6.0 by Sebastian Bergmann.

@sebastianbergmann
Copy link
Owner

I cannot reproduce this.

@tmysik
Copy link
Author

tmysik commented Nov 2, 2011

Exact steps to reproduce:

  • download NetBeans PHP IDE (using dev builds myself)
  • open PHP project with unit tests
  • right click project and select Code Coverage > Collect and Display Code Coverage
  • open any test file
  • Run File (or SHIFT + F6)
  • open the Output window (Window > Output > Output), the error is there

PHPUnit installed and updated via PEAR.

Thanks.

@sebastianbergmann
Copy link
Owner

I will not install an IDE to reproduce a PHPUnit issue.

@sebastianbergmann
Copy link
Owner

Although I was unable to reproduce your issue, 36bbe32 might be somehow related.

@tmysik
Copy link
Author

tmysik commented Nov 2, 2011

Great, you are so nice!

gapon@cattie ~/NetBeansProjects/Calculator/test $ /usr/bin/phpunit --log-junit /tmp/nb-phpunit-log.xml --coverage-clover /tmp/nb-phpunit-coverage.xml CalculatorTest.php

PHPUnit 3.6.0 by Sebastian Bergmann.

PHP Notice: Undefined index: addUncoveredFilesFromWhitelist in /usr/share/php/PHPUnit/TextUI/TestRunner.php on line 254
PHP Stack trace:
PHP 1. {main}() /usr/bin/phpunit:0
PHP 2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:46
PHP 3. PHPUnit_TextUI_Command->run() /usr/share/php/PHPUnit/TextUI/Command.php:126
PHP 4. PHPUnit_TextUI_TestRunner->doRun() /usr/share/php/PHPUnit/TextUI/Command.php:188
PHP Fatal error: Uncaught exception 'InvalidArgumentException' in /usr/share/php/PHP/CodeCoverage.php:386
Stack trace:
#0 /usr/share/php/PHPUnit/TextUI/TestRunner.php(255): PHP_CodeCoverage->setProcessUncoveredFilesFromWhitelist(NULL)
#1 /usr/share/php/PHPUnit/TextUI/Command.php(188): PHPUnit_TextUI_TestRunner->doRun(Object(PHPUnit_Framework_TestSuite), Array)
#2 /usr/share/php/PHPUnit/TextUI/Command.php(126): PHPUnit_TextUI_Command->run(Array, true)
#3 /usr/bin/phpunit(46): PHPUnit_TextUI_Command::main()
#4 {main}
thrown in /usr/share/php/PHP/CodeCoverage.php on line 386

@sebastianbergmann
Copy link
Owner

Did you try it with the patch above? Do you have a phpunit.xml file?

@tmysik
Copy link
Author

tmysik commented Nov 2, 2011

Did you try it with the patch above?

No.

Do you have a phpunit.xml file?

No.

@edorian
Copy link
Contributor

edorian commented Nov 3, 2011

I could reproduce it with 3.6.0.

In bankaccount:

phpunit --bootstrap tests/autoload.php tests/ 

But it seems the --coverage-text fix solved that issue too as it doesn't happen when running from master

@tmysik
Copy link
Author

tmysik commented Nov 4, 2011

Still reproducible for me with PHPUnit 3.6.1. Why cannot I reopen this issue??

gapon@cattie ~/NetBeansProjects/Calculator-test $ /usr/bin/phpunit --log-junit /tmp/nb-phpunit-log.xml --coverage-clover /tmp/nb-phpunit-coverage.xml CalculatorTest.php
PHPUnit 3.6.1 by Sebastian Bergmann.

Notice: Undefined index: addUncoveredFilesFromWhitelist in /usr/share/php/PHPUnit/TextUI/TestRunner.php on line 256

Call Stack:
0.0002 645488 1. {main}() /usr/bin/phpunit:0
0.0065 1301072 2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:46
0.0065 1301984 3. PHPUnit_TextUI_Command->run() /usr/share/php/PHPUnit/TextUI/Command.php:126
0.0827 4203928 4. PHPUnit_TextUI_TestRunner->doRun() /usr/share/php/PHPUnit/TextUI/Command.php:188

Fatal error: Uncaught exception 'InvalidArgumentException' in /usr/share/php/PHP/CodeCoverage.php on line 386

InvalidArgumentException: in /usr/share/php/PHP/CodeCoverage.php on line 386

Call Stack:
0.0002 645488 1. {main}() /usr/bin/phpunit:0
0.0065 1301072 2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:46
0.0065 1301984 3. PHPUnit_TextUI_Command->run() /usr/share/php/PHPUnit/TextUI/Command.php:126
0.0827 4203928 4. PHPUnit_TextUI_TestRunner->doRun() /usr/share/php/PHPUnit/TextUI/Command.php:188
0.0917 4936904 5. PHP_CodeCoverage->setProcessUncoveredFilesFromWhitelist() /usr/share/php/PHPUnit/TextUI/TestRunner.php:257

@tmysik
Copy link
Author

tmysik commented Nov 4, 2011

Fixed in 3.6.2. Now the issue should have been marked as CLOSED and FIXED.

gapon@cattie ~/NetBeansProjects/Calculator-test $ /usr/bin/phpunit --log-junit /tmp/nb-phpunit-log.xml --coverage-clover /tmp/nb-phpunit-coverage.xml CalculatorTest.php
PHPUnit 3.6.2 by Sebastian Bergmann.

....

Time: 1 second, Memory: 7.00Mb

OK (4 tests, 4 assertions)

Writing code coverage data to XML file, this may take a moment.

igorw pushed a commit to igorw-forks/phpunit that referenced this issue Nov 8, 2011
hashar pushed a commit to hashar/phpunit that referenced this issue Nov 9, 2011
@poisa
Copy link

poisa commented Feb 24, 2013

I just updated PHPUnit and I'm getting this bug. It only happens when I try to generate a code coverage report.

PHP_CodeCoverage 1.2.8
PHP 5.3.14
PHPUnit 3.7.14


Notice: Undefined index: addUncoveredFilesFromWhitelist in /Users/Poisa/Sites/phpunit_bug/vendor/phpunit/phpunit/PHPUnit/TextUI/TestRunner.php on line 732

Call Stack:
    0.0019     633272   1. {main}() /Users/Poisa/pear/bin/phpunit:0
    0.0111    1908736   2. PHPUnit_TextUI_Command::main() /Users/Poisa/pear/bin/phpunit:46
    0.0112    1909464   3. PHPUnit_TextUI_Command->run() /Users/Poisa/pear/share/pear/PHPUnit/TextUI/Command.php:130
    0.0920    6345624   4. PHPUnit_TextUI_TestRunner->doRun() /Users/Poisa/pear/share/pear/PHPUnit/TextUI/Command.php:177
    0.0920    6346360   5. PHPUnit_TextUI_TestRunner->handleConfiguration() /Users/Poisa/Sites/phpunit_bug/vendor/phpunit/phpunit/PHPUnit/TextUI/TestRunner.php:139

PHPUnit 3.7.14 by Sebastian Bergmann.

Configuration read from /Users/Poisa/Sites/phpunit_bug/tests/phpunit.xml

................................................

Time: 2 seconds, Memory: 14.00Mb

OK (48 tests, 90 assertions)

Generating code coverage report in HTML format ... done

Here's my xml config:

<phpunit bootstrap="bootstrap.php" colors="true" verbose="true">
    <testsuite name="Crop">
        <directory>./</directory>
    </testsuite>

    <filter>
        <whitelist>
            <directory suffix=".php">tests/</directory>
        </whitelist>
    </filter>
    <logging>
        <log type="coverage-html" target="./report" charset="UTF-8" yui="true" highlight = "true" lowUpperBound="50" highLowerBound="80" />
    </logging>
</phpunit>

@whatthejeff
Copy link
Contributor

@poisa, your stack trace looks strange. Seems PHPUnit files are being loaded from two different locations:

  • /Users/Poisa/Sites/phpunit_bug/vendor/phpunit/phpunit/PHPUnit
  • /Users/Poisa/pear/share/pear/PHPUnit

Could this be related?

@poisa
Copy link

poisa commented Feb 24, 2013

Great catch! I had PHPUnit installed via composer for this particular test project and some files were being read from my PEAR install. I upgraded PEAR's version to the latest and all is good. I will uninstall one of them so it all runs from where it should.

Thanks!

@whatthejeff
Copy link
Contributor

No problem :)

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

5 participants