MantisBT

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0001088XdebugUsage problems (Wrong Results)public2014-11-16 12:332014-12-02 21:28
Reporterdeeped 
Assigned Toderick 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformWindowsOS7OS Version
Product Version2.2.5 
Target VersionFixed in Version2.2.7 
Summary0001088: xdebug wont show dead and not executed lines at the 2nd time
DescriptionHere 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
Attached Filesgif file icon code.gif [^] (36,908 bytes) 2014-11-16 12:33

- Relationships

-  Notes
(0002925)
derick (administrator)
2014-12-02 21:28

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 13:36 derick Category Usage problems => Usage problems (Crashes)
2016-07-31 13:38 derick Category Usage problems (Crashes) => Usage problems (Wrong Results)


Copyright © 2000 - 2017 MantisBT Team
Powered by Mantis Bugtracker