View Issue Details

IDProjectCategoryView StatusLast Update
0001088XdebugUncategorizedpublic2014-12-02 21:28
Reporterdeeped Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
PlatformWindowsOS7 
Product Version2.2.5 
Fixed in Version2.2.7 
Summary0001088: xdebug wont show dead and not executed lines at the 2nd time
Description

Here is a "test":

class TestMe
{
public function test_ok()
{
$a = new TestMe2();
$a->test_forgotToCall();
}

public function test_deadcode()
{
    $a = 1;
    return;
    $a = 'this line wont be executed';
}

public function test_notExecuted()
{
    $a = 'this line wont be executed';
}

}

class TestMe2
{
public function test_forgotToCall()
{
$a = 1; // I "accidentally" forget to call this at the 2nd test
}

public function test2()
{
    $a = 1;
}

}

xdebug_start_code_coverage (XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);
$testObj = new TestMe();
$testObj->test_ok();
$testObj->test_deadcode();
//$testObj->test_notExecuted(); so not executed
var_dump (xdebug_get_code_coverage());
xdebug_stop_code_coverage();

xdebug_start_code_coverage (XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);
$testObj = new TestMe2();
//$testObj->test_forgotToCall();
$testObj->test2();
var_dump (xdebug_get_code_coverage());
xdebug_stop_code_coverage();

the first test runs OK, but at the 2nd time, xdebug_get_code_coverage() just wont show the "unused" and "deadcode" lines, only the rans. If I pass false to xdebug_stop_code_coverage() then it does, but then the covered lines are "summed" so the fact that I forgot to test the test_forgotToCall() function will never turns our. (TestMe calls test_forgotToCall() so it will be covered. But TestMe2 doesnt call it, so test_forgotToCall() must be uncovered, but since TestMe had called it, it just wont turn out

http://i.stack.imgur.com/ka2u1.gif

TagsNo tags attached.
Operating System
PHP Version5.4.2

Activities

derick

2014-12-02 21:28

administrator   ~0002925

Fixed for 2.2.7 and 2.3.0dev, through https://github.com/xdebug/xdebug/pull/134