diff options
author | Andreas Fischer <bantu@phpbb.com> | 2013-11-29 13:53:11 +0100 |
---|---|---|
committer | Andreas Fischer <bantu@phpbb.com> | 2013-11-29 13:53:11 +0100 |
commit | 4171ef9ed79d71f8e2ba0253c5e6bed15f08712b (patch) | |
tree | 846a4424d6f64a016c2bef390c6464040280f5b0 /tests/lint_test.php | |
parent | afb4585dd904de6f5ce4be2607cc90d0cb9def09 (diff) | |
download | forums-4171ef9ed79d71f8e2ba0253c5e6bed15f08712b.tar forums-4171ef9ed79d71f8e2ba0253c5e6bed15f08712b.tar.gz forums-4171ef9ed79d71f8e2ba0253c5e6bed15f08712b.tar.bz2 forums-4171ef9ed79d71f8e2ba0253c5e6bed15f08712b.tar.xz forums-4171ef9ed79d71f8e2ba0253c5e6bed15f08712b.zip |
[ticket/12046] Use PHP_BINARY environment variable in PHP lint test.
PHPBB3-12046
Diffstat (limited to 'tests/lint_test.php')
-rw-r--r-- | tests/lint_test.php | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/tests/lint_test.php b/tests/lint_test.php index 905067072d..d83ac0c652 100644 --- a/tests/lint_test.php +++ b/tests/lint_test.php @@ -9,17 +9,30 @@ class phpbb_lint_test extends phpbb_test_case { + static protected $php_binary; static protected $exclude; static public function setUpBeforeClass() { + // Try to use PHP_BINARY constant if available so lint tests are run + // using the same php binary as phpunit. If not available (pre PHP + // 5.4), assume binary is called 'php' and is in PATH. + self::$php_binary = defined('PHP_BINARY') ? escapeshellcmd(PHP_BINARY) : 'php'; + $output = array(); $status = 1; - exec('(php -v) 2>&1', $output, $status); + exec(sprintf('(%s --version) 2>&1', self::$php_binary), $output, $status); if ($status) { $output = implode("\n", $output); - self::markTestSkipped("php is not in PATH or broken: $output"); + if (self::$php_binary === 'php') + { + self::markTestSkipped(sprintf('php is not in PATH or broken. Output: %s', $output)); + } + else + { + self::markTestSkipped(sprintf('Could not run PHP_BINARY %s. Output: %s', self::$php_binary, $output)); + } } self::$exclude = array( @@ -61,13 +74,12 @@ class phpbb_lint_test extends phpbb_test_case } else if (substr($filename, strlen($filename)-4) == '.php') { - // assume php binary is called php and it is in PATH - $cmd = '(php -l ' . escapeshellarg($path) . ') 2>&1'; + $cmd = sprintf('(%s -l %s) 2>&1', self::$php_binary, escapeshellarg($path)); $output = array(); $status = 1; exec($cmd, $output, $status); $output = implode("\n", $output); - $this->assertEquals(0, $status, "php -l failed for $path:\n$output"); + $this->assertEquals(0, $status, "PHP lint failed for $path:\n$output"); } } } |