/** * Tries to find the system's PHP executable and returns it. * * @return string */ public static function getExecutable() { if (is_null(self::$executable)) { if (getenv('PHP_PATH')) { self::$executable = getenv('PHP_PATH'); if (!is_executable(self::$executable)) { throw new Exception('The defined PHP_PATH environment variable is not a valid PHP executable.'); } } else { self::$executable = PHP_BINDIR . DIRECTORY_SEPARATOR . 'php'; } } if (!is_executable(self::$executable)) { $path = getenv('PATH') ? getenv('PATH') : getenv('Path'); $extensions = DIRECTORY_SEPARATOR == '\\' ? getenv('PATHEXT') ? explode(PATH_SEPARATOR, getenv('PATHEXT')) : array('.exe', '.bat', '.cmd', '.com') : array(''); foreach (array('php5', 'php') as $executable) { foreach ($extensions as $extension) { foreach (explode(PATH_SEPARATOR, $path) as $dir) { $file = $dir . DIRECTORY_SEPARATOR . $executable . $extension; if (is_executable($file)) { self::$executable = $file; break 3; } } } } if (!is_executable(self::$executable)) { throw new Exception("Unable to find PHP executable."); } } return self::$executable; }
public function __construct($plan = null, array $options = array()) { $this->options = array('base_dir' => null, 'output' => 'tap', 'force_colors' => false, 'verbose' => false, 'serialize' => false, 'coverage' => false); foreach (LimeShell::parseArguments($GLOBALS['argv']) as $argument => $value) { $this->options[str_replace('-', '_', $argument)] = $value; } $this->options = array_merge($this->options, $options); $this->options['base_dir'] = realpath($this->options['base_dir']); list($file, $line) = LimeTrace::findCaller('LimeTest'); if ($this->options['coverage']) { $this->output = new LimeOutputCoverage(); } elseif (is_string($this->options['output'])) { $factory = new LimeOutputFactory($this->options); $this->output = $factory->create($this->options['output']); } else { $this->output = $this->options['output']; } $this->output->focus($file); if (!is_null($plan)) { $this->output->plan($plan); } set_error_handler(array($this, 'handleError')); // make sure that exceptions that are not caught by the test runner are // caught and formatted in an appropriate way set_exception_handler(array($this, 'handleException')); }
public function __construct($file, array $arguments = array()) { foreach ($arguments as $argument => $value) { $arguments[$argument] = '--' . $argument; if ($value !== true) { if (!is_string($value)) { $value = var_export($value, true); } $arguments[$argument] .= '=' . escapeshellarg($value); } } $this->errorFile = tempnam(sys_get_temp_dir(), 'lime'); // see http://trac.symfony-project.org/ticket/5437 for the explanation on the weird "cd" thing $this->command = sprintf('cd & %s %s %s 2>%s', escapeshellarg(LimeShell::getExecutable()), escapeshellarg($file), implode(' ', $arguments), $this->errorFile); }
public function __construct(array $options = array()) { $this->options = array_merge(array('base_dir' => null, 'executable' => null, 'output' => 'summary', 'force_colors' => false, 'verbose' => false, 'serialize' => false, 'processes' => 1), $options); foreach (LimeShell::parseArguments($GLOBALS['argv']) as $argument => $value) { $this->options[str_replace('-', '_', $argument)] = $value; } $this->options['base_dir'] = realpath($this->options['base_dir']); if (is_string($this->options['output'])) { $factory = new LimeOutputFactory($this->options); $type = $this->options['output']; $output = $factory->create($type); } else { $output = $this->options['output']; $type = get_class($output); } if ($this->options['processes'] > 1 && !$output->supportsThreading()) { throw new LogicException(sprintf('The output "%s" does not support multi-processing', $type)); } $this->output = new LimeOutputInspectable($output); }