0

unit tests for PECL extensions and how to make them work

Posted by Gabriel on Dec 4, 2009 in pecl, php

Recently I’ve been installing a few PECL extensions, I dev on Snow Leopard which is PHP 5.3 but my colod server is Ubuntu 8.04 LTS which is PHP 5.2, so being me I ignored the various warnings on the sqlite3 page of php.net ( Note: This extension was briefly a PECL extension but that version is only recommended for experimental use. ).
I managed to get the extension installed fine ( phpize, ./configure, sudo make, sudo make install )

wget http://pecl.php.net/get/sqlite3-0.6.tgz
tar xvzf sqlite3-0.6.tgz
cd sqlite3-0.6/
phpize
./configure
sudo make
sudo make install

Now the last line for make install asks you kindly to “Don’t forget to run ‘make test’.”
So let’s do that
Lots of output

Variations on that line appear about 20 times, it seems to be looking in a directory relative to the sqlite3-0.6 directory for the modules
The lovely Cyberspice has made an entry about this already
building php c extensions on ubuntu 9.10
unfortunately I didn’t see this until after I went my own, different route.
Thanks to Derick in #php.pecl on efnet I came up with this bit of code

TEST_PHP_EXECUTABLE=`which php` php /home/gabriel/sqlite3-0.6/run-tests.php /home/gabriel/sqlite3-0.6/tests/*.phpt

which then outputs
Lots of output

So I’d chalk that up as a win, there might be things that get missed running it like this, but I’m not sure.
You can either just run that line of code in the shell or have it in a bash script and then build the bash script to accept parameters so it becomes a lot more customisable.

Tags: , ,

Copyright © 2010 Random Rantings of a Demented Mind All rights reserved. Theme by Laptop Geek.