And figure out a way to deal with them.

For example: http://imagebin.ca/view/TyoeOu.html

Comments

boombatower’s picture

boombatower’s picture

Title: Determine why Xdebug reports empty lines in templates as having been executed » Deal with Xdebug inconsistencies

Marking #639102: wrong coverage on curly brace after return statement in favor of general Xdebug issue.

Recording lines that come back with XDEBUG_CC_DEAD_CODE partly solves the issue, but oddly doesn't solve it completely.

Index: code_coverage.xdebug.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/code_coverage/code_coverage.xdebug.inc,v
retrieving revision 1.7
diff -u -r1.7 code_coverage.xdebug.inc
--- code_coverage.xdebug.inc	12 Mar 2010 21:41:00 -0000	1.7
+++ code_coverage.xdebug.inc	12 Mar 2010 23:34:20 -0000
@@ -33,7 +33,7 @@
 
   // Start Xdebug code coverage and register shutdown function to collect the
   // results and place them in the log table.
-  xdebug_start_code_coverage();
+  xdebug_start_code_coverage(XDEBUG_CC_DEAD_CODE);
   drupal_register_shutdown_function('code_coverage_record', $coverage_set, !empty($_GET['code_coverage']));
 }
 
sun’s picture

The mentioned flag + the UNUSED flag is used by the patch in #983808: Fix Simpletest integration

However, the overall results are very poor, even with the latest Xdebug stable. For example, code coverage report tells me that an experimental class (which happens to live within a file that has been loaded) is 100% covered, even though the class is never instantiated. Same behavior with procedural code in a .module file.

sun’s picture

Looks like this is just simply a logic error. We currently do:

        // Insert all line information into log table.
        $insert = db_insert('code_coverage_log', $db_options)->fields(array('file_id', 'line'));
        foreach ($lines as $line => $count) {
          // Ignore line 0.
          if ($line) {
            $insert->values(array(

but the combined XDEBUG_CC_DEAD_CODE | XDEBUG_CC_UNUSED flag leads to $count being negative for affected lines, as explained by the xdebug maintainer in http://www.slideshare.net/sebastian_bergmann/analysing-php-code

Thus, should be

          if ($line && $count) {

Will incorporate that into #983808: Fix Simpletest integration

sun’s picture

Of course, it must be

          if ($line && $count > 0) {

http://twitter.com/#!/tha_sun/statuses/82248712830730243

berdir’s picture

Nice find, do we need to do something additional with that? For example, to mark dead code (closing } in functions as in the presentation) to not show up as untested? I haven't looked at the results yet.

boombatower’s picture

Assigned: Unassigned » boombatower
Status: Active » Fixed

I just pushed a bunch of commits that were developed for ReviewDriven. I believe this is now fixed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.