From df5fd3ba0949819120d8e8e3c04456721dca08ee Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 23 Dec 2016 15:01:05 +0100 Subject: [PATCH] Cache executable finder calls --- tests/Composer/TestCase.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/Composer/TestCase.php b/tests/Composer/TestCase.php index 1eca8108b..1d1784600 100644 --- a/tests/Composer/TestCase.php +++ b/tests/Composer/TestCase.php @@ -22,6 +22,7 @@ use Symfony\Component\Process\ExecutableFinder; abstract class TestCase extends \PHPUnit_Framework_TestCase { private static $parser; + private static $executableCache = array(); public static function getUniqueTmpDirectory() { @@ -94,9 +95,13 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase */ protected function skipIfNotExecutable($executableName) { - $finder = new ExecutableFinder(); + if (!isset(self::$executableCache[$executableName])) { + $finder = new ExecutableFinder(); + self::$executableCache[$executableName] = (bool) $finder->find($executableName); + } - if (!$finder->find($executableName)) + if (false === self::$executableCache[$executableName]) { $this->markTestSkipped($executableName . ' is not found or not executable.'); + } } }