qa:runtests:howtorun

This is an old revision of the document!


Running the standard version of run-tests.php

run-tests.php can invoked in a number of different ways. Developers tend to invoke it using make, like this:

make test TESTS=path/to/test 

Or like this from the top level directory in the PHP source tree

TEST_EXECUTABLE_PHP=auto sapi/cli/php run-tests.php path/to/test

People running tests tend to use a script file in their bin directory like this:

#!/bin/sh
export TEST_PHP_EXECUTABLE=/mnt/workspace/PHP/php53/sapi/cli/php
$TEST_PHP_EXECUTABLE /mnt/workspace/PHP/php53/run-tests.php $*

Running the new version of run-tests.php

Extract the code

Checkout the code from the PHP svn repository like this:

svn co http://svn.php.net/repository/php/phpruntests/trunk

Under the phpruntests directory you will find all the source code under the directory /src and all of the unit tests under the directory /tests. The main program is called run-tests.php. The main program is located in the directory /src.

Create a test runner

Create a script called 'runtests' in your bin directory (or any directory that is on your PATH) with this content:

#!/bin/sh 
export TEST_PHP_EXECUTABLE=/location/of/php_to_test/sapi/cli/php 
$TEST_PHP_EXECUTABLE /where/you/put/runtests/run-tests.php $* 

In the same way as the original script, this version demands that the PHP executable is set before it will run.

Run the code

At the moment the code will run a single test, eg:

  • runtests my_test.phpt

All the tests under a given directory, eg:

  • runtests ext/standard/tests/

The output format is different to run-tests.php. If a single test is run a short summary is printed to stdout. If one or more directories of tests are run _all_ of the output is saved till the end of the run. Again, a summary is printed to stdout but details are written to a file.

See --help for options.

Running the unit tests for run-tests.php

  • Install PHPUnit
  • Install phing
  • Install Xdebug

There is a build.xml file in the source which will run all the tests and produce a code coverage report (but only if you have Xdebug installed). In the phpruntests directory, type:

phing test

Tests can be run one at a time using PHPUnit. I do this using the Eclipse command line.

Note: Some tests require a PHP executable to run. The executable is found using this:

$this->php = trim(shell_exec(“which php”));

Which works on Unix but will not work on Windows, it might if cygwin is installed but I haven't tried.

QA for run-tests.php

In the QA directory there is a tar file with a standard set of tests. A README in the same directory has instructions on how to use this to check the code. Developers are expected to run this kind of check (in addition to running unit tests) when making significant changes to the code.

A n explanation of the current differences between the old versions of run-tests.php and this one for the set of QA tests is maintained here.

There are a few tests which fail occasionally both with the new and the old version of the code. In the standard set of QA tests these are:

  • ext/phar/tests/zip/phar_stub.phpt
  • ext/standard/tests/mail/mail_variation2.phpt
  • ext/standard/tests/mail/mail_basic2.phpt

Wider ranging tests indicate that there are some tests for the sockets extension that do the same thing

  • ext/sockets/tests/ipv4loop.phpt
  • ext/sockets/tests/socket_create_listen.phpt
  • ext/sockets/tests/socket_set_block-retval.phpt
  • ext/sockets/tests/socket_set_nonblock-retval.phpt

We don't have an explanation for this at the moment.

Configure options

The current QA checks use the standard (no options) configure. However as we develop we are extending this to be able to run as many options as possible. This page has a set of configure options that have been tried.

current state:

./configure --prefix=/Users/g2/php/ --with-config-file-path=/Users/g2/php/php53/ --with-pear=/opt/local/ --with-iconv=/opt/local --with-bz2=/opt/local/ --with-zlib=/opt/local/ --with-libxml-dir=/opt/local --with-gettext=/opt/local --with-libexpat-dir=/opt/local --with-freetype-dir=/opt/local --with-openssl=/opt/local/ --with-t1lib=/opt/local/ --with-tidy=/opt/local --with-xsl=/opt/local --with-curl=/opt/local --with-pcre-regex=/opt/local --with-gd --with-jpeg-dir=/opt/local --with-png-dir=/opt/local --with-mhash=/opt/local --with-mcrypt=/opt/local --with-readline=/opt/local --enable-fastcgi --disable-short-tags --enable-pcntl --enable-soap --enable-exif --enable-sockets --enable-sysvsem --enable-sysvshm --with-xml --enable-sysvmsg --enable-calendar --enable-exif --with-xmlrpc --enable-ftp --enable-wdd --enable-soap --enable-bcmath --enable-mbstring --enable-dba --enable-zip --with-mime-magic --enable-gd-native-ttf --enable-xdebug

Further Information on configure
qa/runtests/howtorun.1250707127.txt.gz · Last modified: 2017/09/22 13:28 (external edit)