qa:testcoverage

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
qa:testcoverage [2008/04/30 19:44] – created zoeqa:testcoverage [2017/09/22 13:28] (current) – external edit 127.0.0.1
Line 1: Line 1:
 ==== How to look at the test coverage for an extension - eg /ext/dom ==== ==== How to look at the test coverage for an extension - eg /ext/dom ====
  
-   * Make sure that you have LTP installed +  * Make sure that you have LTP installed, for Ubuntu: 
-      * sudo apt-get install ltp (on Ubuntu)+      * sudo apt-get install ltp 
       * sudo apt-get install lcov       * sudo apt-get install lcov
 +
 +=== Checkout the PHP53 code and build it ===
 +  * Checkout or download PHP53 into directory of your choice (in my case /home/zoe/BUILDS/php53_dev)
 +  * cd /home/zoe/BUILDS/php53_dev
 +  * ./buildconf
 +  * ./configure --enable-gcov
 +  * make
 +
 +=== Check the coverage of a single extension ===
 +  * make a new directory somewhere (eg /home/zoe/TESTS/coverage) and cd to it
 +  * create a script (run_coverage) file to run the tests, eg
 +<code>
 +export TEST_PHP_EXECUTABLE=/home/zoe/BUILDS/php53_dev/sapi/cli/php
 +$TEST_PHP_EXECUTABLE /home/zoe/BUILDS/php53_dev/run-tests.php /home/zoe/BUILDS/php53_dev/ext/dom
 +</code>
 +   * ./run_coverage. This runs all the tests found under php53_dev/ext/dom
 +   * lcov --directory /home/zoe/BUILDS/php53_dev/ext/dom -c -o dom.info
 +   * genhtml dom.info -o dom_coverage. This will make a directory called dom_coverage with html coverage files in it.
 +   * View the coverage files :-)
 +
 +==== How would I look at the coverage of a subset of the tests? ====
 +For example - suppose I wanted to take all the tests which are there because of bug reports and just look at what the base test cases cover.
 +  * cd /home/zoe/BUILDS/php53_dev/ext/dom
 +  * '' find tests -name "bug*.phpt" | xargs -i mv {} {}.bak ''   ( Copies all the tests to test.phpt.bak ) 
 +  * make clean; make
 +  * cd /home/zoe/TESTS/coverage; ./runcov.sh run
 +  * run lcov and genhtml as above
 +
 +Just for interest, the code coverage of the dom extension without the bug tests is 2101 of 4708 lines (44.6%).
 +
 +Don't forget to copy the bug tests back afterwards:
 +  * '' find tests -name "bug*.phpt.bak" | sed 's/.bak/ /' | xargs -i mv {}.bak {} ''
 +  * NB: no space between the two slashes after .bak
 +
 +
 +
 +
  
qa/testcoverage.1209584666.txt.gz · Last modified: 2017/09/22 13:28 (external edit)