From 62e6c49c4c09d86b3b1060d8dd4d265919bcbc0f Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Fri, 14 Jun 2019 14:21:47 -0400 Subject: [PATCH] tools/scripts/phpunit - Flip back to preferring 'php' for subprocess Rationale: * On the test servers, `php` is wrapper script. * Outside the test servers, you should be able to use `phpunit` directly (rather than calling `tools/scripts/phpunit`), and then it's not our problem. --- tools/scripts/phpunit | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/tools/scripts/phpunit b/tools/scripts/phpunit index fd28402746..671c4d7440 100755 --- a/tools/scripts/phpunit +++ b/tools/scripts/phpunit @@ -87,12 +87,20 @@ $cmd = passthru($cmd); function findPhp() { - if (defined('PHP_BINARY')) { - return PHP_BINARY; // php 5.4+ - } elseif (defined('PHP_BINDIR') && file_exists(PHP_BINDIR . '/php')) { - return PHP_BINDIR . '/php'; // php 5.3 - } else { - die("Failed to determine active PHP version."); + // The autodetect behavior here is a potential point of contention. These two cases are hard to reconcile: + // 1. `php` is actually a wrapper script which delegates to another PHP binary and + // passes options (such as INI's and PECL extensions). Subprocesses should use the wrapper script. + // Examples: bitnami, bknix + // 2. There are multiple PHP binaries (eg `php55`, `php70`). Subprocesses should use + // the final executable (regardless of its name). + // Example: using MAMP and adding 'ln -s /Application/MAMP/.../php7.1.2/bin/php ~/bin/php71` + // Since the test infra uses a wrapper script like (1), we use autodetect logic that works there. + // If you're in situation (2), then set an env-var or just skip on using `tools/scripts/phpunit`. + if (getenv('PHP')) { + return getenv('PHP'); + } + else { + return 'php'; } } -- 2.25.1