# [PATCH] Autoguessing TEST_PHP_EXECUTABLE if none is provided in run-tests.php

- Thread: https://externals.io/message/55304
- Original archive: https://news-web.php.net/php.internals/55304
- Started by Alexey Shein on 2011-09-08T12:07:07+00:00
- Messages: 6
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #55304 — Alexey Shein — 2011-09-08T12:07:07+00:00

URL: https://externals.io/message/55304#55304

Hello!
I've made some improvements to run-tests.php:
1) Autoguessing TEST_PHP_EXECUTABLE and TEST_PHP_CGI_EXECUTABLE if
they're not provided, i.e. assume they have value 'auto'. You can
still pass your own value as usual.
2) Added option -n (use no php.ini) to the shebang line
(#!/usr/bin/php -n) so it would run more reliably on some hosts. My
Ubuntu setup did not have E letter in variables_order (i.e.
variables_order=GPCS) so $_ENV array was empty and some tests were
skipped when they could be run.
3) Some better error handling of wrong paths

So now you can run run-tests.php with just
$ ./run-tests.php ext
instead of
$ TEST_PHP_EXECUTABLE=auto php -n run-tests.php ext

You can also run run-tests.php from sub-dir, it will correctly guess
'auto' as well:
$ cd ext/
$ ../run-tests.php zlib

Please, review this patch and, if there's no objections, I will
prepare 5.4 and 5.3 versions too.

-- 
Regards,
Shein Alexey

---

## #55306 — Ferenc Kovacs — 2011-09-08T13:00:12+00:00

URL: https://externals.io/message/55304#55306 · In reply to: #55304

> Hello!
> I've made some improvements to run-tests.php:
> 1) Autoguessing TEST_PHP_EXECUTABLE and TEST_PHP_CGI_EXECUTABLE if
> they're not provided, i.e. assume they have value 'auto'. You can
> still pass your own value as usual.
> 2) Added option -n (use no php.ini) to the shebang line
> (#!/usr/bin/php -n) so it would run more reliably on some hosts. My
> Ubuntu setup did not have E letter in variables_order (i.e.
> variables_order=GPCS) so $_ENV array was empty and some tests were
> skipped when they could be run.
> 3) Some better error handling of wrong paths
>
> So now you can run run-tests.php with just
> $ ./run-tests.php ext
> instead of
> $ TEST_PHP_EXECUTABLE=auto php -n run-tests.php ext
>
> You can also run run-tests.php from sub-dir, it will correctly guess
> 'auto' as well:
> $ cd ext/
> $ ../run-tests.php zlib
>
> Please, review this patch and, if there's no objections, I will
> prepare 5.4 and 5.3 versions too.

for the record, the "Don't ever guess at the PHP executable location."
comments was made back in 2002
http://svn.php.net/viewvc?view=revision&revision=82472 and at time the
part of the code which guessed the php binary was pretty messy, so I
think that now we would be safe to use the "auto" for default.

-- 
Ferenc Kovács
@Tyr43l - http://tyrael.hu

---

## #55342 — Christopher Jones — 2011-09-09T18:03:27+00:00

URL: https://externals.io/message/55304#55342 · In reply to: #55304

> Hello!
> I've made some improvements to run-tests.php:
> 1) Autoguessing TEST_PHP_EXECUTABLE and TEST_PHP_CGI_EXECUTABLE if
> they're not provided, i.e. assume they have value 'auto'. You can
> still pass your own value as usual.
> 2) Added option -n (use no php.ini) to the shebang line
> (#!/usr/bin/php -n) so it would run more reliably on some hosts. My
> Ubuntu setup did not have E letter in variables_order (i.e.
> variables_order=GPCS) so $_ENV array was empty and some tests were
> skipped when they could be run.
> 3) Some better error handling of wrong paths
>
> So now you can run run-tests.php with just
> $ ./run-tests.php ext
> instead of
> $ TEST_PHP_EXECUTABLE=auto php -n run-tests.php ext
>
> You can also run run-tests.php from sub-dir, it will correctly guess
> 'auto' as well:
> $ cd ext/
> $ ../run-tests.php zlib
>
> Please, review this patch and, if there's no objections, I will
> prepare 5.4 and 5.3 versions too.
>
>
>
>

I don't have a problem with the intent to make it easier and more
failsafe.  In particular I'm +1 on autoguessing, which might be a
marginally contentious change for some developers.

A few of us build PHP outside the svn source tree.  The following
modification to your patch fixes the intended autodetection in this
scenario:

     if ($php == 'auto') {
         $php = realpath($CUR_DIR . '/sapi/cli/php');
         if (!$php) {
             $php = realpath(__DIR__ . '/sapi/cli/php');
         }
         putenv("TEST_PHP_EXECUTABLE=$php");
     }
     $environment['TEST_PHP_EXECUTABLE'] = $php;


It allows the following to work for me:

     cd ~/phpbuild
     ./sapi/cli/php -n ~/phpsrc/php/php-src/branches/PHP_5_4/run-tests.php /tmp/array_bind_001.phpt

Since run-tests.php is kept in sync on all branches, you'll only need
one version of the patch.

Chris

-- 
Email: christopher.jones@oracle.com
Tel:  +1 650 506 8630
Blog:  http://blogs.oracle.com/opal/

---

## #55343 — Alexey Shein — 2011-09-09T18:11:44+00:00

URL: https://externals.io/message/55304#55343 · In reply to: #55342

2011/9/9 Christopher Jones <christopher.jones@oracle.com>:
>
>
> 
> > […]
>
> I don't have a problem with the intent to make it easier and more
> failsafe.  In particular I'm +1 on autoguessing, which might be a
> marginally contentious change for some developers.
>
> A few of us build PHP outside the svn source tree.  The following
> modification to your patch fixes the intended autodetection in this
> scenario:
>
>    if ($php == 'auto') {
>        $php = realpath($CUR_DIR . '/sapi/cli/php');
>        if (!$php) {
>            $php = realpath(__DIR__ . '/sapi/cli/php');
>        }
>        putenv("TEST_PHP_EXECUTABLE=$php");
>    }
>    $environment['TEST_PHP_EXECUTABLE'] = $php;
>
>
> It allows the following to work for me:
>
>    cd ~/phpbuild
>    ./sapi/cli/php -n ~/phpsrc/php/php-src/branches/PHP_5_4/run-tests.php
> /tmp/array_bind_001.phpt
>
> Since run-tests.php is kept in sync on all branches, you'll only need
> one version of the patch.

So you mean to check sapi/cli/php in the current dir first and, if not
found, further in the directory related to run-tests.php (PHP_5_4 in
your example). Ok, that makes sense, usual running from svn tree will
not be changed.


> Chris
>
> --
> Email: christopher.jones@oracle.com
> Tel:  +1 650 506 8630
> Blog:  http://blogs.oracle.com/opal/
>
> --
> 
> 
>
>



-- 
Regards,
Shein Alexey

---

## #55469 — Alexey Shein — 2011-09-16T08:36:57+00:00

URL: https://externals.io/message/55304#55469

It seems last message didn't go to the list, resending

2011/9/12 Alexey Shein <confik@gmail.com>:
> Created bug report here, included Christopher's suggestion into the patch:
> https://bugs.php.net/bug.php?id=55672

Please, review the patch and tell me if there are any objections not to take it.
Thank you.

-- 
Regards,
Shein Alexey

---

## #55623 — Felipe Pena — 2011-09-24T17:50:18+00:00

URL: https://externals.io/message/55304#55623 · In reply to: #55304

2011/9/8 Alexey Shein <confik@gmail.com>:
> Hello!
> I've made some improvements to run-tests.php:
> 1) Autoguessing TEST_PHP_EXECUTABLE and TEST_PHP_CGI_EXECUTABLE if
> they're not provided, i.e. assume they have value 'auto'. You can
> still pass your own value as usual.
> 2) Added option -n (use no php.ini) to the shebang line
> (#!/usr/bin/php -n) so it would run more reliably on some hosts. My
> Ubuntu setup did not have E letter in variables_order (i.e.
> variables_order=GPCS) so $_ENV array was empty and some tests were
> skipped when they could be run.
> 3) Some better error handling of wrong paths
>
> So now you can run run-tests.php with just
> $ ./run-tests.php ext
> instead of
> $ TEST_PHP_EXECUTABLE=auto php -n run-tests.php ext
>
> You can also run run-tests.php from sub-dir, it will correctly guess
> 'auto' as well:
> $ cd ext/
> $ ../run-tests.php zlib
>
> Please, review this patch and, if there's no objections, I will
> prepare 5.4 and 5.3 versions too.
>
> --
> Regards,
> Shein Alexey
>

+1

I have no tried the patch, but the additions sounds good to me.

-- 
Regards,
Felipe Pena
