This is an old revision of the document!
PEAR QA Continuous Integration and Unit Tests
There are a number of tools qa use to maintain quality.
PHPCS and General QA tools
http://test.pear.php.net/ hosts continuous integration tools
The helper scripts live at http://svn.php.net/viewvc/pear/ci/phpuc/trunk/
Cruise Control
Cruise Control is a continuous integration platform. Currently, all packages in both PEAR and PEAR2 are built by it.
The build task does:
- Update svn
- Run
$ phpunit --log-junit ... tests/AllTests.php
(if AllTests.php is present) - Run
$ phpunit --log-junit ... tests/
(if .phpt is present) - Run
$ phpmd path/to/package/trunk xml codesize,unusedcode,naming --reportfile ...
- Run
$ phpcpd path/to/package/trunk --log-pmd ...
- Run
$ phpcs --report=checkstyle --standard=PEAR --ignore=tests path/to/package/trunk
- Build the package with Pyrus
$ php /path/to/pyrus.phar package -o .../trunk.tar.gz
If either the unit tests or building the package fails, the build is marked as a failure.
A file, called trunk.tar.gz is created as a build artifact.
How do I make sure my tests work?
In general, we encourage the use of an AllTests.php - we target PHPUnit 3.4 at this time.
Your package directory layout should allow you to successfully run your test suite as below:
$ cd Foo_Bar/trunk $ php tests/AllTests.php
The continuous integration box does this slightly differently:
Todo
- Fix how pear2-packages-all and pear2/all relate to the test suite
- Generate a changelog, package.xml file (possibly in pearweb, possible on the command line) automatically; and build off of that.
- Investigate what's up with the Metrics and other Cruise Control errors
- Investigate a notification task to package maintainers?
- Investigate allowing bootstrapped build.xml files back in (Pyrus)
- Upgrade PHP on test.pear.php.net
- Install xdebug for proper code coverage
How to test a new PEAR release
Before releasing a new version of PEAR, we need to make sure it runs on as many systems as possible. It's pretty easy:
- Install the new PEAR (1.7.0RC2 currently)
- Make sure you have the XML_RPC package
- Checkout pear-core from CVS to get the tests
- Run the tests
pear upgrade -f PEAR pear upgrade XML_RPC cvs -d :pserver:cvsread@cvs.php.net:/repository checkout pear-core cd pear-core/tests && pear run-tests -r
Tell pear-qa@lists.php.net if you got failures, and if, which tests did not pass. We will come back to you in that case.
Common pitfalls
- Make sure that PHP is compiled with tokenizer support (--enable-tokenizer). On most systems this is default, but on Gentoo Linux for instance, you need to enable the tokenizer USE flag.
- For some tests the executable php-cgi is needed. In some Linux distributions this is contained in a separate package, but on for instance Gentoo Linux this has to be enabled using the cgi USE flag.
- If running on linux, do not run the tests as root