scripts/run-tests.sh hard codes /usr/bin/php as its interpreter. This patch seamlessly discovers your interpreter in 99% of use cases. For the others, it adds the ability to pass in the path to your php as a command line argument.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

moshe weitzman’s picture

FileSize
1.65 KB

Help from DamZ - now SUDO_COMMAND case gets only the interpreter

Dries’s picture

Interesting little patch. Can you add a line documentation the $_ENV['_']; case? I'm not familiar with $_ENV['_'];. We might want to add a line about SUDO_COMMAND too. Thanks!

moshe weitzman’s picture

FileSize
2.02 KB

Added comments and error handling in case when php path cannot be found and was not supplied.

moshe weitzman’s picture

FileSize
2.52 KB

Now with escapeshellarg($php) and typos fixed in code comments.

moshe weitzman’s picture

FileSize
2.58 KB

Added a comment above escapeshellarg() and changed php => PHP three times.

Damien Tournoud’s picture

Here is a fix for the patch in #5, should be ready to go in as-is.

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

Thanks a bunch, Damien. Code and functionality look good.

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD! Thanks for the improvements. I like. :)

boombatower’s picture

Status: Fixed » Active

First off this no longer works on SUSE 11.0 with PHP in /usr/bin/php which is annoying.

I can get it to run by using --php with path, but when I try to run tests the error pops up again. I'm guess it doesn't pass it along correctly.

Anyone confirm?

webchick’s picture

@boombatower: If you revert this patch, do you still get the same problem? I found a bug where if you run this via ./run-tests.sh (rather than php run-tests.sh) you get tons of errors, but it happened before this patch too.

boombatower’s picture

It runs without patch and I don't have to specify --php.

It appears to be a bit more quirky then when I left it (even without patch). :(

I can't just do:

php ./scripts/run-tests.sh Profile

Instead I have to use --class or something else...either bad documentation or borken.

but it runs when I do that. I get 34 fails....hmm

seems to be quiet broken.

clemens.tolboom’s picture

(// $Id: run-tests.sh,v 1.12 2008/09/24 19:00:31 webchick Exp $)

It's weird to run a '.sh' script with php. I was about to commit a shebang #!/usr/bin/php patch but now I don't know if this script is intended to run like ./scripts/run-tests.sh. If not why not replace the extension to '.php'?

When running as a normal user or www-data (not rootphp ./scripts/run-tests.sh --list lists nothing. Running tests from admin/build/testing is doing ok.

moshe weitzman’s picture

@clemens - i agree, but thats a separate issue. this script used to be called run-functional-tests and had a .php extension at one time. see http://cvs.drupal.org/viewvc.py/drupal/drupal/scripts/?pathrev=DRUPAL-6. i don't know why it extension.

fyi, drush's shebang is '#!/usr/bin/env php' which is slightly prefereable AFAIK.

Damien Tournoud’s picture

Having a shebang will make us loose the ability to autodetect the path of the running PHP interpreter. For simpletest, it is *critical* that we know this information and that child scripts are run in the exact same interpreter => I guess this is a won't fix, but documentation could be improved (for example, it is not stated anywhere that run-tests should be ran using the exact same user as Apache).

The .sh extension is there to prevent the script from being executed by Apache. There are other solutions (detecting the sapi, using .htaccess, etc.). Improvements are welcome.

I don't see why running php thru even is better. Could someone explain this?

moshe weitzman’s picture

Status: Active » Fixed

The remaining gripes are not elated to this patch. Please open new issues as needed.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.