Codeception / c3

Remote CodeCoverage for Codeception. Part of Codeception testing framework.
http://codeception.com
71 stars 46 forks source link

Code Coverage HTML report exhausting all available memory #5

Closed olemartinorg closed 11 years ago

olemartinorg commented 11 years ago

Hi!

When i'm trying to set up and use code coverage in my codeception tests, i sometimes get this error message:

[UnexpectedValueException]
phar error: "/tmp/C3VVS4ea.tar" is a corrupted tar file (checksum mismatch of file "
Fatal error: Allowed memory size of 402653184 bytes exhausted (tried to allocate 16384 bytes) in /v")

And the content of /tmp/C3VVS4ea.tar includes a full stack trace:

Fatal error: Allowed memory size of 402653184 bytes exhausted (tried to allocate 16384 bytes) in /var/www/vendor/phpunit/php-token-stream/PHP/Token/Stream.php on line 218

Call Stack:
    0.0065     633440   1. {main}() /var/www/c3.php:0
    2.7317  114615016   2. __c3_build_html_report() /var/www/c3.php:209
    2.8414  114681360   3. PHP_CodeCoverage_Report_HTML->process() /var/www/c3.php:43
    2.8473  114681576   4. PHP_CodeCoverage->getReport() /var/www/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/HTML.php:120
    2.8632  114744664   5. PHP_CodeCoverage_Report_Factory->create() /var/www/vendor/phpunit/php-code-coverage/PHP/CodeCoverage.php:158
    3.1713  121803584   6. PHP_CodeCoverage_Report_Factory->addItems() /var/www/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/Factory.php:75
    3.1714  121808952   7. PHP_CodeCoverage_Report_Factory->addItems() /var/www/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/Factory.php:97
    3.1714  121814192   8. PHP_CodeCoverage_Report_Factory->addItems() /var/www/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/Factory.php:97
    3.1715  121819432   9. PHP_CodeCoverage_Report_Factory->addItems() /var/www/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/Factory.php:97
   17.8675  342026336  10. PHP_CodeCoverage_Report_Factory->addItems() /var/www/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/Factory.php:97
   21.9244  395074008  11. PHP_CodeCoverage_Report_Node_Directory->addFile() /var/www/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/Factory.php:93
   21.9244  395077600  12. PHP_CodeCoverage_Report_Node_File->__construct() /var/www/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/Node/Directory.php:210
   22.5187  399288184  13. PHP_CodeCoverage_Report_Node_File->calculateStatistics() /var/www/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/Node/File.php:171
   22.5187  399290080  14. PHP_Token_Stream->__construct() /var/www/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/Node/File.php:413
   22.5188  399316352  15. PHP_Token_Stream->scan() /var/www/vendor/phpunit/php-token-stream/PHP/Token/Stream.php:152

I'm not the expert, it seems the code coverage html reports are stored fully in memory at all times, and with big reports it may end up crashing.

olemartinorg commented 11 years ago

And this happens when i run without HTML reports and only a clover/xml report:

Fatal error: Allowed memory size of 402653184 bytes exhausted (tried to allocate 262144 bytes) in /var/www/vendor/phpunit/php-token-stream/PHP/Token/Stream.php on line 218

Call Stack:
    0.0076     633536   1. {main}() /var/www/c3.php:0
    0.2505   32746568   2. __c3_build_clover_report() /var/www/c3.php:216
    0.2608   32878008   3. PHP_CodeCoverage_Report_Clover->process() /var/www/c3.php:74
    0.2629   32880952   4. PHP_CodeCoverage->getReport() /var/www/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/Clover.php:84
    0.2688   32943920   5. PHP_CodeCoverage_Report_Factory->create() /var/www/vendor/phpunit/php-code-coverage/PHP/CodeCoverage.php:158
    0.4848   38600248   6. PHP_CodeCoverage_Report_Factory->addItems() /var/www/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/Factory.php:75
    7.1035  290564728   7. PHP_CodeCoverage_Report_Factory->addItems() /var/www/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/Factory.php:97
    7.1035  290569968   8. PHP_CodeCoverage_Report_Factory->addItems() /var/www/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/Factory.php:97
    7.1035  290575208   9. PHP_CodeCoverage_Report_Factory->addItems() /var/www/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/Factory.php:97
    7.1035  290580464  10. PHP_CodeCoverage_Report_Factory->addItems() /var/www/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/Factory.php:97
    7.5394  317721680  11. PHP_CodeCoverage_Report_Factory->addItems() /var/www/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/Factory.php:97
    7.5394  317729872  12. PHP_CodeCoverage_Report_Factory->addItems() /var/www/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/Factory.php:97
    7.7680  330202928  13. PHP_CodeCoverage_Report_Factory->addItems() /var/www/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/Factory.php:97
    7.7680  330208168  14. PHP_CodeCoverage_Report_Factory->addItems() /var/www/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/Factory.php:97
    7.7681  330213408  15. PHP_CodeCoverage_Report_Factory->addItems() /var/www/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/Factory.php:97
    8.5925  355621776  16. PHP_CodeCoverage_Report_Node_Directory->addFile() /var/www/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/Factory.php:93
    8.5926  355625368  17. PHP_CodeCoverage_Report_Node_File->__construct() /var/www/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/Node/Directory.php:210
    9.3146  378835096  18. PHP_CodeCoverage_Report_Node_File->calculateStatistics() /var/www/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/Node/File.php:171
    9.3147  378837032  19. PHP_Token_Stream->__construct() /var/www/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/Node/File.php:413
    9.3225  378929784  20. PHP_Token_Stream->scan() /var/www/vendor/phpunit/php-token-stream/PHP/Token/Stream.php:152
olemartinorg commented 11 years ago

Found a related issue in phpunit: https://github.com/sebastianbergmann/phpunit/issues/597

And it links to this: http://blog.sbw.be/2010/11/30/continuous-integration-phpunit-code-coverage-use-a-bit-less-than-2-gigs/

Looks like I'll have to bite the bullet and just give the VM more memory. A bit sad, when i only ran one single codeception test to try this out, and it already exceeded the memory limit.. :-/

tiger-seo commented 11 years ago

Hi, Try to exclude vendors and other files not owned by you.