1

I'm working on a Symfony2 bundle and ran phpunit --coverage-text. All tests pass without any problems and I received a code coverage report, but it was incomplete and at the bottom there is the following message.

Classes: 4.08% (2/49)
Methods: 1.94% (12/619)
Lines:   1.60% (46/2867)
..
....  
zend_mm_heap corrupted

I am on PHP 5.4.11 and I'm running the latest versions of PHPUnit and xdebug. PHPUnit always runs properly, except when I ask it to do code coverage. Here is the relevant part of my PHPUnit configuration file.

    <testsuites>
        <testsuite name="My Suite">
            <directory>./src/Company/*Bundle/Tests</directory>
        </testsuite>
    </testsuites>

    <filter>
        <whitelist>
            <directory suffix=".php">./src/Company/*Bundle/</directory>
        </whitelist>
    </filter>

I figured that it was either a memory or output buffering problem, so I tried upping the following ini directives.

output_buffering = 8192
memory_limit = 1028M

This removed the previous error but I started receiving instead a segmentation fault 11 error instead.

How do you get rid of these problems?

Jarrod Nettles
  • 6,193
  • 6
  • 28
  • 46

2 Answers2

0

The problem seems to be that the folder containing the unit tests are a part of the bundle, and therefore were included in the code coverage report. I don't know the specifics of what goes wrong in PHPUnit, but if your unit tests are located in your bundle you need to make sure that they are specifically filtered from the code coverage.

Here is my new phpunit.xml configuration file (relevant parts). No zend_mm_heap and no segmentation fault.

    <testsuites>
        <testsuite name="My Suite">
            <directory>./src/Company/*Bundle/Tests</directory>
        </testsuite>
    </testsuites>

    <filter>
        <whitelist>
            <directory suffix=".php">./src/Company/*Bundle/</directory>
            <exclude>
                <directory>./src/*/*Bundle/Tests</directory>
            </exclude>
        </whitelist>
    </filter>
Jarrod Nettles
  • 6,193
  • 6
  • 28
  • 46
  • Symfony2 ships with a phpunit.xml.dist config file that takes care of this for you. If you're like me and started your own config from scratch its handy to remember. – Jarrod Nettles Feb 17 '13 at 22:59
  • I have the same problem, but for me it only happens with the text format. All the others work fine. – Dynom May 15 '13 at 08:14
  • Also see http://stackoverflow.com/questions/2247977/what-does-zend-mm-heap-corrupted-mean – Ben Oct 24 '13 at 05:31
0

You need to use

<filter>
  <whitelist processUncoveredFilesFromWhitelist="true">
    <directory suffix=".php">/path/to/files</directory>
    <file>/path/to/file</file>
    <exclude>
      <directory suffix=".php">/path/to/files</directory>
      <file>/path/to/file</file>
    </exclude>
  </whitelist>
</filter>

to filter the source files for coverage report

Feng Xu
  • 13
  • 3