Skip to content

Commit

Permalink
Merge pull request #508 from Automattic/fix/rulesettest-dont-use-syst…
Browse files Browse the repository at this point in the history
…em-default-php

RulesetTest: don't use the system default version of PHP
  • Loading branch information
GaryJones authored Jul 22, 2020
2 parents 2c70364 + bea4a24 commit 4c5007b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tests/RulesetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,17 @@ private function run() {
* @return array Returns an associative array with keys of `totals` and `files`.
*/
private function collect_phpcs_result() {
$shell = sprintf( '%1$s --severity=1 --standard=%2$s --report=json ./%2$s/ruleset-test.inc', $this->phpcs_bin, $this->ruleset );
$php = '';
if ( \PHP_BINARY && in_array( \PHP_SAPI, [ 'cgi-fcgi', 'cli', 'cli-server', 'phpdbg' ], true ) ) {
$php = \PHP_BINARY . ' ';
}

$shell = sprintf(
'%1$s%2$s --severity=1 --standard=%3$s --report=json ./%3$s/ruleset-test.inc',
$php, // Current PHP executable if avaiable.
$this->phpcs_bin,
$this->ruleset
);
// phpcs:ignore
$output = shell_exec( $shell );

Expand Down

0 comments on commit 4c5007b

Please sign in to comment.