This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 245353 - Code coverage not available
Summary: Code coverage not available
Status: RESOLVED FIXED
Alias: None
Product: php
Classification: Unclassified
Component: Atoum (show other bugs)
Version: 8.0.1
Hardware: All All
: P3 normal (vote)
Assignee: Tomas Mysik
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-07-02 06:06 UTC by Tomas Mysik
Modified: 2014-07-30 11:59 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
mageekguy.atoum.phar (2.61 MB, application/octet-stream)
2014-07-23 22:16 UTC, jubianchi
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tomas Mysik 2014-07-02 06:06:03 UTC
From e-mail from Julien:
------------------------------
You should be able to use it from the phar like this:

$ php mageekguy.atoum.phar --use coverage --output clover.xml

When using atoum sources, the command line is a bit different:

$ php scripts/coverage.php --output clover.xml
------------------------------
Comment 1 Tomas Mysik 2014-07-08 15:28:19 UTC
Should be fixed now. Láďo, could you please test it with PHAR as well as with "atoum" file (from cloned repository)? Also, please test it on Windows as well as on Linux. Thanks a lot!

Thanks Julien for all your help!

http://hg.netbeans.org/web-main/rev/63ecbcb928f8
http://hg.netbeans.org/web-main/rev/0b676e4dea01
http://hg.netbeans.org/web-main/rev/a582bff57005
Comment 2 Vladimir Riha 2014-07-08 15:34:43 UTC
Sure, I'll try it but likely on sooner than on Thursday/Friday
Comment 3 Vladimir Riha 2014-07-21 10:20:56 UTC
Reopening based on email from Julien:

The thing here is that Netbeans is passing CLI argument before the --use which does not work.
For the command to work properly, we have to call the phar like this:

 "/usr/bin/php" "/home/vriha/phplib/mageekguy.atoum.phar" "--use" "coverage" "--output" "/tmp/nb-atoum-coverage.xml" "-d" "/tmp/Calculator-atoum/test" "-utr"
Comment 4 Tomas Mysik 2014-07-21 10:47:58 UTC
Julien, just to be sure, could you please provide also the command for the cloned repository (not PHAR file but plenty of files).

Thanks!
Comment 5 jubianchi 2014-07-21 11:54:05 UTC
For the record, here are the command to use when ruuning atoum from Phar or from sources:

* From Phar:

$ php mageekguy.atoum.phar --use 'coverage' --output "/tmp/nb-atoum-coverage.xml" "-d" "/tmp/Calculator-atoum/test" "-utr"

* From sources:

$ php <path/to/atoum/root>/scripts/coverage.php --output "/tmp/nb-atoum-coverage.xml" "-d" "/tmp/Calculator-atoum/test" "-utr"

Both commands should produce the exact same output and reports.
Comment 6 Tomas Mysik 2014-07-22 07:06:49 UTC
And if we have bootstrap and/or configuration, we can add them as the first parameters (right after PHAR or "coverage" files), right?

Thanks.
Comment 7 Tomas Mysik 2014-07-22 07:11:05 UTC
Looking into the code, I see that we use also Xdebug (-xc) and filter (-m) params - where to put these, please? Currently, we put them right before the "-d" parameter.

Láďo, please, try to test at least some combinations once I fix it, thanks :)
Comment 8 Tomas Mysik 2014-07-22 07:14:56 UTC
(In reply to Tomas Mysik from comment #7)
> Looking into the code, I see that we use also Xdebug (-xc) and filter (-m)
> params - where to put these, please? Currently, we put them right before the
> "-d" parameter.

Apparently it does not work... :/

"/usr/bin/php" "/home/gapon/tmp/atoum/mageekguy.atoum.phar" "--use" "coverage" "--output" "/tmp/nb-atoum-coverage.xml" "-m" "tests\unit\Calculator::testMinus" "-d" "/home/gapon/NetBeansProjects/Calculator-atoum1/test" "-utr"

Error: Argument '--output' is unknown, did you mean '-drt'?
Comment 9 Tomas Mysik 2014-07-22 07:16:20 UTC
Julien, one more issue - if I run [1], the tests are run OK but the coverage file is not generated at all (it does not exist on the disk). Any idea, please?

Thanks.
[1] "/usr/bin/php" "/home/gapon/tmp/atoum/mageekguy.atoum.phar" "--use" "coverage" "--output" "/tmp/nb-atoum-coverage.xml" "-d" "/home/gapon/NetBeansProjects/Calculator-atoum1/test" "-utr"
Comment 10 Tomas Mysik 2014-07-22 07:24:22 UTC
So, the NetBeans side should be fixed, I hope. But as I wrote (see my previous comments), no coverage file is generated and also one cannot use "-m" parameter (I did not try to debug any test).

Julien, could you please look at it and help us? Or should not we return to the previous state - run 2 commands, one for test results and the other one for coverage?

Please, let us know, thanks.

http://hg.netbeans.org/web-main/rev/fcc8b6551b5f
Comment 11 jubianchi 2014-07-22 09:47:48 UTC
I'm on it ;)
Comment 12 jubianchi 2014-07-22 10:08:19 UTC
@Tomas @Vladimir I found the bug, it was on my side : I should be able to fix it quickly and provide an new, working Phar.

I'll keep you updated.

Sorry.
Comment 13 jubianchi 2014-07-22 10:17:02 UTC
Ok, so I got everything working from sources:

$ php vendor/atoum/atoum/scripts/coverage.php "--output" "clover.xml" "-d" "tests/" "-utr" # TAP report OK, coverage report OK in clover.xml

$ php vendor/atoum/atoum/scripts/coverage.php "--output" "clover.xml" "-m" "tests\\units\\netbeans\\sample\\Calculator::testMultiply" "-d" "tests/" "-utr" # TAP report OK, coverage report OK in clover.xml, only the selected method is run

We can also use the -c argument to include additional configuration files:

$ php vendor/atoum/atoum/scripts/coverage.php "--output" "clover.xml" "-m" "tests\\units\\netbeans\\sample\\Calculator::testMultiply" "-d" "tests/" "-utr" -c /tmp/.atoum.php +verbose # TAP report OK, coverage report OK in clover.xml, only the selected method is run and the extra config. file is used

Note that you can use the +verbose or ++verbose arguments so that atoum will let you know which config files, bootstrap files and tests files it uses.

Now, it's time to build the phar :)
Comment 14 Tomas Mysik 2014-07-22 10:36:37 UTC
Perfect, simply attach the PHAR file here. Thanks!

I will move the config/bootstrap files parameters to the end of the command.

Thanks!
Comment 15 Tomas Mysik 2014-07-22 10:43:47 UTC
(In reply to Tomas Mysik from comment #14)
> I will move the config/bootstrap files parameters to the end of the command.

Done. Láďo, please do not forget to debug unit tests (it will add -xc parameter).

Thanks.

http://hg.netbeans.org/web-main/rev/ddabce0d8454
Comment 16 Quality Engineering 2014-07-23 02:08:06 UTC
Integrated into 'main-silver', will be available in build *201407230001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/fcc8b6551b5f
User: Tomas Mysik <tmysik@netbeans.org>
Log: #245353 - Code coverage not available
Comment 17 jubianchi 2014-07-23 22:16:22 UTC
Created attachment 148248 [details]
mageekguy.atoum.phar

Here is the new phar. I tested every command in my previous comment with the phar and some other combinations. Everything seemed to work ;)
Comment 18 Tomas Mysik 2014-07-24 05:46:35 UTC
Thanks a lot, Julien!
Comment 19 Vladimir Riha 2014-07-25 12:48:39 UTC
Thanks for the phar, I tried it works fine without debugging but once I try to debug file while code coverage is on, it doesn't work

php "/home/vriha/phplib/mageekguy.atoum_nightly.phar" "--use" "coverage" "--output" "/tmp/nb-atoum-coverage.xml" "-xc" "idekey=netbeans-xdebug" "-f" "/home/vriha/Downloads/Calculator-atoum1/test/Calculator.php" "-utr"

Error: Argument '--output' is unknown, did you mean '-drt'?
Done.


Product Version: NetBeans IDE Dev (Build 201407250001)
Java: 1.8.0_05; Java HotSpot(TM) Client VM 25.5-b02
Runtime: Java(TM) SE Runtime Environment 1.8.0_05-b13
System: Linux version 3.13.0-32-generic running on i386; UTF-8; en_US (nb)
Comment 20 Tomas Mysik 2014-07-25 12:57:12 UTC
Julien, maybe the [1] param must be at the end of the command? Or should we disable coverage for debugging?

Thanks.
[1] "-xc" "idekey=netbeans-xdebug"
Comment 21 Vladimir Riha 2014-07-25 13:00:32 UTC
I tried the same with atoum file from cloned repository and it works fine in this case, code coverage is displayed even with debugging

"/usr/bin/php" "/home/vriha/phplib/atoum/atoum/scripts/coverage.php" "--output" "/tmp/nb-atoum-coverage.xml" "-xc" "idekey=netbeans-xdebug" "-f" "/home/vriha/Downloads/Calculator-atoum1/test/Calculator.php" "-utr"
Comment 22 Tomas Mysik 2014-07-25 13:01:59 UTC
So it seems to me to be atoum issue - right, Julien?

Thanks.
Comment 23 jubianchi 2014-07-25 16:55:36 UTC
I'm checking this behavior on the atoum side. 
If it comes from atoum it should not be hard to fix. 

I'm on it and I'll try to provide a working phar and master asap ;)
Comment 24 jubianchi 2014-07-25 17:34:50 UTC
I can't reproduce the bug with the last phar I provided.

Here is what I have: I cloned github.com/jubianchi/atoum-sample inside my atoum (master) working copy:

.
├── [ 782]  atoum-master
│   ├── [ 442]  atoum-sample

Then I cd'ed into atoum-sample and ran:

$ php ../mageekguy.atoum.phar "--use" "coverage" "--output" "/tmp/nb-atoum-coverage.xml" "-xc" "idekey=netbeans-xdebug" -f tests/units/netbeans/sample/Calculator.php "-utr"

Everything worked fine:

1..3
ok 1
# tests\units\netbeans\sample\Calculator::testMultiply()
ok 2
# tests\units\netbeans\sample\Calculator::testDivide()
ok 3
# tests\units\netbeans\sample\Calculator::testAdd()

And the clover is OK:

$ cat /tmp/nb-atoum-coverage.xml

<?xml version="1.0" encoding="UTF-8"?>
<coverage generated="1406309597" clover="53d294dd467db">
  <project timestamp="1406309597" name="atoum code coverage">
    <package name="atoumCodeCoverage">
      <file name="Calculator.php" path="/Users/jubianchi/repositories/atoum/atoum-master/atoum-sample/src/netbeans/sample/Calculator.php">
        <line num="8" type="stmt" complexity="0" count="1" falsecount="0" truecount="0" signature="" testduration="0" testsuccess="0"/>
        <line num="13" type="stmt" complexity="0" count="1" falsecount="0" truecount="0" signature="" testduration="0" testsuccess="0"/>
        <line num="14" type="stmt" complexity="0" count="1" falsecount="0" truecount="0" signature="" testduration="0" testsuccess="0"/>
        <line num="17" type="stmt" complexity="0" count="1" falsecount="0" truecount="0" signature="" testduration="0" testsuccess="0"/>
        <line num="22" type="stmt" complexity="0" count="1" falsecount="0" truecount="0" signature="" testduration="0" testsuccess="0"/>
        <class name="Calculator">
          <metrics complexity="0" elements="5" coveredelements="5" conditionals="0" coveredconditionals="0" statements="5" coveredstatements="5" methods="3" coveredmethods="3" testduration="0" testfailures="0" testpasses="0" testruns="0"/>
        </class>
        <metrics complexity="0" elements="5" coveredelements="5" conditionals="0" coveredconditionals="0" statements="5" coveredstatements="5" methods="3" coveredmethods="3" testduration="0" testfailures="0" testpasses="0" testruns="0" classes="1" loc="5" ncloc="5"/>
      </file>
      <metrics complexity="0" elements="5" coveredelements="5" conditionals="0" coveredconditionals="0" statements="5" coveredstatements="5" methods="3" coveredmethods="3" testduration="0" testfailures="0" testpasses="0" testruns="0" classes="1" loc="5" ncloc="5" files="1"/>
    </package>
    <metrics complexity="0" elements="5" coveredelements="5" conditionals="0" coveredconditionals="0" statements="5" coveredstatements="5" methods="3" coveredmethods="3" testduration="0" testfailures="0" testpasses="0" testruns="0" classes="1" loc="5" ncloc="5" files="1" packages="1"/>
  </project>
</coverage>

To me, everything is OK. @Vladimir are you sure you used the pahr I pushed here ? https://netbeans.org/bugzilla/attachment.cgi?id=148248
Comment 25 Vladimir Riha 2014-07-26 10:50:31 UTC
Yes, I am using this one. MD5 hash is aac6180956790c10976dfa578920b9a8 . It doesn't work for me even from command line with the atoum-sample project.

$ php -v
PHP 5.5.12-2+deb.sury.org~precise+1 (cli) (built: May 12 2014 13:46:38) 
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
    with Xdebug v2.2.5, Copyright (c) 2002-2014, by Derick Rethans
    with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies
Comment 26 Tomas Mysik 2014-07-29 07:49:02 UTC
(In reply to jubianchi from comment #17)
> Created attachment 148248 [details]
> mageekguy.atoum.phar
> 
> Here is the new phar. I tested every command in my previous comment with the
> phar and some other combinations. Everything seemed to work ;)

Strange, I can confirm that it simply does not work for me, see [1].

Thanks.
[1]
"/usr/bin/php" "/home/gapon/Download/mageekguy.atoum.phar" "--use" "coverage" "--output" "/tmp/nb-atoum-coverage.xml" "-d" "/home/gapon/NetBeansProjects/Calculator-atoum/test" "-utr"
Error: Argument '--output' is unknown, did you mean '-drt'?
Comment 27 jubianchi 2014-07-30 10:42:28 UTC
I finally reproduced the bug.

I'm working ont it.
Comment 28 jubianchi 2014-07-30 11:59:00 UTC
@Tomas @Vladimir SHould be fixed : I pushed a commit on https://github.com/atoum/atoum

I'll build the phar when I get home and upload it here after confirming that it works.