From 4c58a0bcb22aea9eda8211b9a557311cdccbb442 Mon Sep 17 00:00:00 2001 From: "Meredith L. Patterson" <mlp@thesmartpolitenerd.com> Date: Sat, 23 Nov 2013 16:07:19 -0600 Subject: [PATCH] php tests run on clean build --- SConstruct | 2 +- src/bindings/php/README.md | 10 ++++++++-- src/bindings/php/SConscript | 17 ++++++++++++----- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/SConstruct b/SConstruct index 8a801f76..dac01075 100644 --- a/SConstruct +++ b/SConstruct @@ -93,9 +93,9 @@ env["ENV"].update(x for x in os.environ.items() if x[0].startswith("CCC_")) #rootpath = env['ROOTPATH'] = os.path.abspath('.') #env.Append(CPPPATH=os.path.join('#', "hammer")) -env['testruns'] = [] testruns = [] + targets = ["$libpath", "$incpath", "$parsersincpath", diff --git a/src/bindings/php/README.md b/src/bindings/php/README.md index 1c9f0fb4..8e11cb9e 100644 --- a/src/bindings/php/README.md +++ b/src/bindings/php/README.md @@ -1,12 +1,18 @@ -Installing -========== +Building +======== Requirements: * SWIG 2.0 * A properly configured [phpenv](https://github.com/CHH/phpenv) +SCons finds your PHP include path from `php-config`, so if you don't have that working, you're going to have a bad time. + If you want to run the tests, you will also need to install PHPUnit. Do this with pyrus and save yourself some hell. pyrus channel-discover pear.phpunit.de pyrus channel-discover pear.symfony.com pyrus channel-discover pear.symfony-project.com pyrus install --optionaldeps phpunit/PHPUnit + +Installing +========== +We're not building a proper package yet, but you can copy `build/$VARIANT/src/bindings/php/hammer.so` to your PHP extension directory (`scons test` will do this for you if you're using phpenv; for a system-wide php you'll probably have to use sudo) and add "extension=hammer.so" to your php.ini. There is a "hammer.ini" in src/bindings/php for your convenience; you can put it in the `conf.d` directory where PHP expects to find its configuration. `scons test` will do this for you too. \ No newline at end of file diff --git a/src/bindings/php/SConscript b/src/bindings/php/SConscript index bed12266..aa9a5357 100644 --- a/src/bindings/php/SConscript +++ b/src/bindings/php/SConscript @@ -1,6 +1,6 @@ # -*- python -*- import os, os.path -Import('env libhammer_shared') +Import('env libhammer_shared testruns') phpenv = env.Clone(IMPLICIT_COMMAND_DEPENDENCIES = 0) @@ -17,8 +17,15 @@ Default(swig_src, bindings_src, libhammer_php) phptestenv = phpenv.Clone() phptestenv['ENV']['LD_LIBRARY_PATH'] = os.path.dirname(str(libhammer_shared[0])) -phptests = ['Tests'] -testphp = phptestenv.Alias("testphp", phptestenv.Command(phptests, [libhammer_php], "phpenv exec phpunit -v --include-path "+os.getcwd()+" $TARGET")) -env['testruns'].append(testphp) -print "Testing: " + str([str(x[0]) for x in env['testruns']]) +phptests = ('Tests') +phpextprefix = os.popen("php-config --extension-dir").read().rstrip() +phplib = phptestenv.Command(os.path.join(phpextprefix, "hammer.so"), libhammer_php, Copy("$TARGET", "$SOURCE")) +phpprefix = os.popen("php-config --prefix").read().rstrip() +phpincl = phptestenv.Command(os.path.join(phpprefix, "hammer.ini"), "hammer.ini", Copy("$TARGET", "$SOURCE")) +phptestexec = phptestenv.Command(phptests, [phplib, phpincl], "phpenv exec phpunit -v --include-path " + os.path.dirname(libhammer_php[0].path) +" src/bindings/php/Tests") +print "phptestexec path: " + phptestexec[0].path +phptest = Alias("testphp", [phptestexec], phptestexec) +AlwaysBuild(phptest) +testruns.append(phptest) +print "Testing: " + str([str(x[0]) for x in testruns]) -- GitLab