mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-07 20:08:53 +00:00
Merge remote-tracking branch 'remotes/bantu/ticket/12046' into develop-olympus
* remotes/bantu/ticket/12046: [ticket/12046] Use PHP_BINARY environment variable in PHP lint test.
This commit is contained in:
commit
90f3cc48e5
1 changed files with 17 additions and 5 deletions
|
@ -9,17 +9,30 @@
|
||||||
|
|
||||||
class phpbb_lint_test extends phpbb_test_case
|
class phpbb_lint_test extends phpbb_test_case
|
||||||
{
|
{
|
||||||
|
static protected $php_binary;
|
||||||
static protected $exclude;
|
static protected $exclude;
|
||||||
|
|
||||||
static public function setUpBeforeClass()
|
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();
|
$output = array();
|
||||||
$status = 1;
|
$status = 1;
|
||||||
exec('(php -v) 2>&1', $output, $status);
|
exec(sprintf('(%s --version) 2>&1', self::$php_binary), $output, $status);
|
||||||
if ($status)
|
if ($status)
|
||||||
{
|
{
|
||||||
$output = implode("\n", $output);
|
$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(
|
self::$exclude = array(
|
||||||
|
@ -65,13 +78,12 @@ class phpbb_lint_test extends phpbb_test_case
|
||||||
}
|
}
|
||||||
else if (substr($filename, strlen($filename)-4) == '.php')
|
else if (substr($filename, strlen($filename)-4) == '.php')
|
||||||
{
|
{
|
||||||
// assume php binary is called php and it is in PATH
|
$cmd = sprintf('(%s -l %s) 2>&1', self::$php_binary, escapeshellarg($path));
|
||||||
$cmd = '(php -l ' . escapeshellarg($path) . ') 2>&1';
|
|
||||||
$output = array();
|
$output = array();
|
||||||
$status = 1;
|
$status = 1;
|
||||||
exec($cmd, $output, $status);
|
exec($cmd, $output, $status);
|
||||||
$output = implode("\n", $output);
|
$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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue