Running ‘redirected’ PHP tests

The first step in implementing the REDIRECTTEST section in parallel runtests code is to get some redirected tests running on my Mac. I’ve used PDO and MySQL, principally because I already had MySQL installed so it seemed the easiest place to start.

This is what I had to do to get them to run:

$cd php/source/code
$./configure --with-zlib --with-pdo-mysql 

Missing the location of mysql.sock results in tests being skipped and errors like this: “SQLSTATE[HY000] [2002] No such file or directory”, it took me a while to work out what it meant.

The PDO tests assume the following if you do not specify properties using environmental variables:

  1. The MySQL database has a user called ‘root’
  2. The ‘root’ user has no password
  3. There is a database called ‘test’

The alternative to using the defaults is to assign some environment variables as follows:

$export PDO_MYSQL_TEST_DSN="mysql:host=localhost;dbname=test"
$export PDO_MYSQL_TEST_USER=your_mysql_uid
$export PDO_MYSQL_TEST_PASS=your_mysql_pwd

After setting those things up I was able to run:

$export TEST_PHP_EXECUTABLE=/php/to/test/php
$php runtests.php  ext/pdo_mysql/tests/common.phpt

The second command assumes that I’m in the top level directory of the PHP source code. The summary output is as follows:

Number of tests : 62 60
Tests skipped : 2 ( 3.2%) ——–
Tests warned : 0 ( 0.0%) ( 0.0%)
Tests failed : 0 ( 0.0%) ( 0.0%)
Expected fail : 0 ( 0.0%) ( 0.0%)
Tests passed : 60 ( 96.8%) (100.0%)

Which is good enough to start work with. I guess the next thing is to work out what the REDIRECTTEST part actually does.