Running the new version of run-tests.php

Extract the code

Checkout the code from the PHP git repository like this:

git clone

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:

export TEST_PHP_EXECUTABLE=/location/of/php_to_test/php 
export TEST_PHP_CGI_EXECUTABLE=/location/of/php_cgi_to_test/php-cgi
$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. You do not need to specify the CGI executable, the run-tests.php code will attempt to guess its location (as the current code does) from the location of the cli.

Run the code

Run a single test, eg:

 runtests my_test.phpt

Run 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 the output is printed after each group (directory) of tests has been run. Again, a summary is printed to stdout but details are written to a file.

Run all the tests under path_to_php/ext in parallel on 4 processors

  runtests path_to_php/ext -z 4

Generate XML formatted output to a file:

  runtests -o xml -s /tmp/somefile path_to_php/tests

Get more verbose results to the screen:

  runtests -vvv path_to_php/tests

Note: there are three levels of verbosity, -v, -vv and -vvv. But default all you will see is a '.' for each test.

runtests --help

will give you all of the possible command line options.

run-tests.php on Windows

Running the code should be the same, you will need a runtests.bat file rather than a shell script.

qa/runtests/howtorun.txt · Last modified: 2017/09/22 13:28 by