View Issue Details

IDProjectCategoryView StatusLast Update
0001088XdebugUncategorizedpublic2014-12-02 21:28
Reporterdeeped Assigned Toderick  
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.
Attached Files
code.gif (36,908 bytes)   
code.gif (36,908 bytes)   
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

Issue History

Date Modified Username Field Change
2014-11-16 12:33 deeped New Issue
2014-11-16 12:33 deeped File Added: code.gif
2014-12-02 21:28 derick Note Added: 0002925
2014-12-02 21:28 derick Status new => closed
2014-12-02 21:28 derick Assigned To => derick
2014-12-02 21:28 derick Resolution open => fixed
2014-12-02 21:28 derick Fixed in Version => 2.2.7
2016-07-31 12:36 derick Category Usage problems => Usage problems (Crashes)
2016-07-31 12:38 derick Category Usage problems (Crashes) => Usage problems (Wrong Results)
2020-03-12 16:35 derick Category Usage problems (Wrong Results) => Variable Display
2020-03-12 16:38 derick Category Variable Display => Uncategorized