the whole shebang
This commit is contained in:
3
vendor/symfony/process/Symfony/Component/Process/.gitignore
vendored
Normal file
3
vendor/symfony/process/Symfony/Component/Process/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
vendor/
|
||||
composer.lock
|
||||
phpunit.xml
|
26
vendor/symfony/process/Symfony/Component/Process/CHANGELOG.md
vendored
Normal file
26
vendor/symfony/process/Symfony/Component/Process/CHANGELOG.md
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
CHANGELOG
|
||||
=========
|
||||
|
||||
2.3.0
|
||||
-----
|
||||
|
||||
* added ProcessUtils::escapeArgument() to fix the bug in escapeshellarg() function on Windows
|
||||
* added Process::signal()
|
||||
* added Process::getPid()
|
||||
* added support for a TTY mode
|
||||
|
||||
2.2.0
|
||||
-----
|
||||
|
||||
* added ProcessBuilder::setArguments() to reset the arguments on a builder
|
||||
* added a way to retrieve the standard and error output incrementally
|
||||
* added Process:restart()
|
||||
|
||||
2.1.0
|
||||
-----
|
||||
|
||||
* added support for non-blocking processes (start(), wait(), isRunning(), stop())
|
||||
* enhanced Windows compatibility
|
||||
* added Process::getExitCodeText() that returns a string representation for
|
||||
the exit code returned by the process
|
||||
* added ProcessBuilder
|
21
vendor/symfony/process/Symfony/Component/Process/Exception/ExceptionInterface.php
vendored
Normal file
21
vendor/symfony/process/Symfony/Component/Process/Exception/ExceptionInterface.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process\Exception;
|
||||
|
||||
/**
|
||||
* Marker Interface for the Process Component.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
interface ExceptionInterface
|
||||
{
|
||||
}
|
21
vendor/symfony/process/Symfony/Component/Process/Exception/InvalidArgumentException.php
vendored
Normal file
21
vendor/symfony/process/Symfony/Component/Process/Exception/InvalidArgumentException.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process\Exception;
|
||||
|
||||
/**
|
||||
* InvalidArgumentException for the Process Component.
|
||||
*
|
||||
* @author Romain Neutron <imprec@gmail.com>
|
||||
*/
|
||||
class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
|
||||
{
|
||||
}
|
21
vendor/symfony/process/Symfony/Component/Process/Exception/LogicException.php
vendored
Normal file
21
vendor/symfony/process/Symfony/Component/Process/Exception/LogicException.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process\Exception;
|
||||
|
||||
/**
|
||||
* LogicException for the Process Component.
|
||||
*
|
||||
* @author Romain Neutron <imprec@gmail.com>
|
||||
*/
|
||||
class LogicException extends \LogicException implements ExceptionInterface
|
||||
{
|
||||
}
|
49
vendor/symfony/process/Symfony/Component/Process/Exception/ProcessFailedException.php
vendored
Normal file
49
vendor/symfony/process/Symfony/Component/Process/Exception/ProcessFailedException.php
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process\Exception;
|
||||
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
/**
|
||||
* Exception for failed processes.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class ProcessFailedException extends RuntimeException
|
||||
{
|
||||
private $process;
|
||||
|
||||
public function __construct(Process $process)
|
||||
{
|
||||
if ($process->isSuccessful()) {
|
||||
throw new InvalidArgumentException('Expected a failed process, but the given process was successful.');
|
||||
}
|
||||
|
||||
parent::__construct(
|
||||
sprintf(
|
||||
'The command "%s" failed.'."\nExit Code: %s(%s)\n\nOutput:\n================\n%s\n\nError Output:\n================\n%s",
|
||||
$process->getCommandLine(),
|
||||
$process->getExitCode(),
|
||||
$process->getExitCodeText(),
|
||||
$process->getOutput(),
|
||||
$process->getErrorOutput()
|
||||
)
|
||||
);
|
||||
|
||||
$this->process = $process;
|
||||
}
|
||||
|
||||
public function getProcess()
|
||||
{
|
||||
return $this->process;
|
||||
}
|
||||
}
|
21
vendor/symfony/process/Symfony/Component/Process/Exception/RuntimeException.php
vendored
Normal file
21
vendor/symfony/process/Symfony/Component/Process/Exception/RuntimeException.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process\Exception;
|
||||
|
||||
/**
|
||||
* RuntimeException for the Process Component.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class RuntimeException extends \RuntimeException implements ExceptionInterface
|
||||
{
|
||||
}
|
90
vendor/symfony/process/Symfony/Component/Process/ExecutableFinder.php
vendored
Normal file
90
vendor/symfony/process/Symfony/Component/Process/ExecutableFinder.php
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process;
|
||||
|
||||
/**
|
||||
* Generic executable finder.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class ExecutableFinder
|
||||
{
|
||||
private $suffixes = array('.exe', '.bat', '.cmd', '.com');
|
||||
|
||||
/**
|
||||
* Replaces default suffixes of executable.
|
||||
*
|
||||
* @param array $suffixes
|
||||
*/
|
||||
public function setSuffixes(array $suffixes)
|
||||
{
|
||||
$this->suffixes = $suffixes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds new possible suffix to check for executable.
|
||||
*
|
||||
* @param string $suffix
|
||||
*/
|
||||
public function addSuffix($suffix)
|
||||
{
|
||||
$this->suffixes[] = $suffix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds an executable by name.
|
||||
*
|
||||
* @param string $name The executable name (without the extension)
|
||||
* @param string $default The default to return if no executable is found
|
||||
* @param array $extraDirs Additional dirs to check into
|
||||
*
|
||||
* @return string The executable path or default value
|
||||
*/
|
||||
public function find($name, $default = null, array $extraDirs = array())
|
||||
{
|
||||
if (ini_get('open_basedir')) {
|
||||
$searchPath = explode(PATH_SEPARATOR, getenv('open_basedir'));
|
||||
$dirs = array();
|
||||
foreach ($searchPath as $path) {
|
||||
if (is_dir($path)) {
|
||||
$dirs[] = $path;
|
||||
} else {
|
||||
$file = str_replace(dirname($path), '', $path);
|
||||
if ($file == $name && is_executable($path)) {
|
||||
return $path;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$dirs = array_merge(
|
||||
explode(PATH_SEPARATOR, getenv('PATH') ?: getenv('Path')),
|
||||
$extraDirs
|
||||
);
|
||||
}
|
||||
|
||||
$suffixes = array('');
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$pathExt = getenv('PATHEXT');
|
||||
$suffixes = $pathExt ? explode(PATH_SEPARATOR, $pathExt) : $this->suffixes;
|
||||
}
|
||||
foreach ($suffixes as $suffix) {
|
||||
foreach ($dirs as $dir) {
|
||||
if (is_file($file = $dir.DIRECTORY_SEPARATOR.$name.$suffix) && (defined('PHP_WINDOWS_VERSION_BUILD') || is_executable($file))) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $default;
|
||||
}
|
||||
}
|
19
vendor/symfony/process/Symfony/Component/Process/LICENSE
vendored
Normal file
19
vendor/symfony/process/Symfony/Component/Process/LICENSE
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2004-2013 Fabien Potencier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
62
vendor/symfony/process/Symfony/Component/Process/PhpExecutableFinder.php
vendored
Normal file
62
vendor/symfony/process/Symfony/Component/Process/PhpExecutableFinder.php
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process;
|
||||
|
||||
/**
|
||||
* An executable finder specifically designed for the PHP executable.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class PhpExecutableFinder
|
||||
{
|
||||
private $executableFinder;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->executableFinder = new ExecutableFinder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds The PHP executable.
|
||||
*
|
||||
* @return string|false The PHP executable path or false if it cannot be found
|
||||
*/
|
||||
public function find()
|
||||
{
|
||||
// PHP_BINARY return the current sapi executable
|
||||
if (defined('PHP_BINARY') && PHP_BINARY && ('cli' === PHP_SAPI) && is_file(PHP_BINARY)) {
|
||||
return PHP_BINARY;
|
||||
}
|
||||
|
||||
if ($php = getenv('PHP_PATH')) {
|
||||
if (!is_executable($php)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $php;
|
||||
}
|
||||
|
||||
if ($php = getenv('PHP_PEAR_PHP_BIN')) {
|
||||
if (is_executable($php)) {
|
||||
return $php;
|
||||
}
|
||||
}
|
||||
|
||||
$dirs = array(PHP_BINDIR);
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$dirs[] = 'C:\xampp\php\\';
|
||||
}
|
||||
|
||||
return $this->executableFinder->find('php', false, $dirs);
|
||||
}
|
||||
}
|
73
vendor/symfony/process/Symfony/Component/Process/PhpProcess.php
vendored
Normal file
73
vendor/symfony/process/Symfony/Component/Process/PhpProcess.php
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process;
|
||||
|
||||
use Symfony\Component\Process\Exception\RuntimeException;
|
||||
|
||||
/**
|
||||
* PhpProcess runs a PHP script in an independent process.
|
||||
*
|
||||
* $p = new PhpProcess('<?php echo "foo"; ?>');
|
||||
* $p->run();
|
||||
* print $p->getOutput()."\n";
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
class PhpProcess extends Process
|
||||
{
|
||||
private $executableFinder;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $script The PHP script to run (as a string)
|
||||
* @param string $cwd The working directory
|
||||
* @param array $env The environment variables
|
||||
* @param integer $timeout The timeout in seconds
|
||||
* @param array $options An array of options for proc_open
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function __construct($script, $cwd = null, array $env = array(), $timeout = 60, array $options = array())
|
||||
{
|
||||
parent::__construct(null, $cwd, $env, $script, $timeout, $options);
|
||||
|
||||
$this->executableFinder = new PhpExecutableFinder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the path to the PHP binary to use.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function setPhpBinary($php)
|
||||
{
|
||||
$this->setCommandLine($php);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function start($callback = null)
|
||||
{
|
||||
if (null === $this->getCommandLine()) {
|
||||
if (false === $php = $this->executableFinder->find()) {
|
||||
throw new RuntimeException('Unable to find the PHP executable.');
|
||||
}
|
||||
$this->setCommandLine($php);
|
||||
}
|
||||
|
||||
parent::start($callback);
|
||||
}
|
||||
}
|
1291
vendor/symfony/process/Symfony/Component/Process/Process.php
vendored
Normal file
1291
vendor/symfony/process/Symfony/Component/Process/Process.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
174
vendor/symfony/process/Symfony/Component/Process/ProcessBuilder.php
vendored
Normal file
174
vendor/symfony/process/Symfony/Component/Process/ProcessBuilder.php
vendored
Normal file
@@ -0,0 +1,174 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process;
|
||||
|
||||
use Symfony\Component\Process\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\Process\Exception\LogicException;
|
||||
|
||||
/**
|
||||
* Process builder.
|
||||
*
|
||||
* @author Kris Wallsmith <kris@symfony.com>
|
||||
*/
|
||||
class ProcessBuilder
|
||||
{
|
||||
private $arguments;
|
||||
private $cwd;
|
||||
private $env;
|
||||
private $stdin;
|
||||
private $timeout;
|
||||
private $options;
|
||||
private $inheritEnv;
|
||||
private $prefix;
|
||||
|
||||
public function __construct(array $arguments = array())
|
||||
{
|
||||
$this->arguments = $arguments;
|
||||
|
||||
$this->timeout = 60;
|
||||
$this->options = array();
|
||||
$this->env = array();
|
||||
$this->inheritEnv = true;
|
||||
}
|
||||
|
||||
public static function create(array $arguments = array())
|
||||
{
|
||||
return new static($arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an unescaped argument to the command string.
|
||||
*
|
||||
* @param string $argument A command argument
|
||||
*
|
||||
* @return ProcessBuilder
|
||||
*/
|
||||
public function add($argument)
|
||||
{
|
||||
$this->arguments[] = $argument;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an unescaped prefix to the command string.
|
||||
*
|
||||
* The prefix is preserved when reseting arguments.
|
||||
*
|
||||
* @param string $prefix A command prefix
|
||||
*
|
||||
* @return ProcessBuilder
|
||||
*/
|
||||
public function setPrefix($prefix)
|
||||
{
|
||||
$this->prefix = $prefix;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $arguments
|
||||
*
|
||||
* @return ProcessBuilder
|
||||
*/
|
||||
public function setArguments(array $arguments)
|
||||
{
|
||||
$this->arguments = $arguments;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setWorkingDirectory($cwd)
|
||||
{
|
||||
$this->cwd = $cwd;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function inheritEnvironmentVariables($inheritEnv = true)
|
||||
{
|
||||
$this->inheritEnv = $inheritEnv;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setEnv($name, $value)
|
||||
{
|
||||
$this->env[$name] = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setInput($stdin)
|
||||
{
|
||||
$this->stdin = $stdin;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the process timeout.
|
||||
*
|
||||
* To disable the timeout, set this value to null.
|
||||
*
|
||||
* @param float|null
|
||||
*
|
||||
* @return ProcessBuilder
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function setTimeout($timeout)
|
||||
{
|
||||
if (null === $timeout) {
|
||||
$this->timeout = null;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
$timeout = (float) $timeout;
|
||||
|
||||
if ($timeout < 0) {
|
||||
throw new InvalidArgumentException('The timeout value must be a valid positive integer or float number.');
|
||||
}
|
||||
|
||||
$this->timeout = $timeout;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setOption($name, $value)
|
||||
{
|
||||
$this->options[$name] = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getProcess()
|
||||
{
|
||||
if (!$this->prefix && !count($this->arguments)) {
|
||||
throw new LogicException('You must add() command arguments before calling getProcess().');
|
||||
}
|
||||
|
||||
$options = $this->options;
|
||||
|
||||
$arguments = $this->prefix ? array_merge(array($this->prefix), $this->arguments) : $this->arguments;
|
||||
$script = implode(' ', array_map(array(__NAMESPACE__.'\\ProcessUtils', 'escapeArgument'), $arguments));
|
||||
|
||||
if ($this->inheritEnv) {
|
||||
$env = $this->env ? $this->env + $_ENV : null;
|
||||
} else {
|
||||
$env = $this->env;
|
||||
}
|
||||
|
||||
return new Process($script, $this->cwd, $env, $this->stdin, $this->timeout, $options);
|
||||
}
|
||||
}
|
64
vendor/symfony/process/Symfony/Component/Process/ProcessUtils.php
vendored
Normal file
64
vendor/symfony/process/Symfony/Component/Process/ProcessUtils.php
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process;
|
||||
|
||||
/**
|
||||
* ProcessUtils is a bunch of utility methods.
|
||||
*
|
||||
* This class contains static methods only and is not meant to be instantiated.
|
||||
*
|
||||
* @author Martin Hasoň <martin.hason@gmail.com>
|
||||
*/
|
||||
class ProcessUtils
|
||||
{
|
||||
/**
|
||||
* This class should not be instantiated
|
||||
*/
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Escapes a string to be used as a shell argument.
|
||||
*
|
||||
* @param string $argument The argument that will be escaped
|
||||
*
|
||||
* @return string The escaped argument
|
||||
*/
|
||||
public static function escapeArgument($argument)
|
||||
{
|
||||
//Fix for PHP bug #43784 escapeshellarg removes % from given string
|
||||
//Fix for PHP bug #49446 escapeshellarg dosn`t work on windows
|
||||
//@see https://bugs.php.net/bug.php?id=43784
|
||||
//@see https://bugs.php.net/bug.php?id=49446
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
if ('' === $argument) {
|
||||
return escapeshellarg($argument);
|
||||
}
|
||||
|
||||
$escapedArgument = '';
|
||||
foreach (preg_split('/([%"])/i', $argument, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE) as $part) {
|
||||
if ('"' === $part) {
|
||||
$escapedArgument .= '\\"';
|
||||
} elseif ('%' === $part) {
|
||||
$escapedArgument .= '^%';
|
||||
} else {
|
||||
$escapedArgument .= escapeshellarg($part);
|
||||
}
|
||||
}
|
||||
|
||||
return $escapedArgument;
|
||||
}
|
||||
|
||||
return escapeshellarg($argument);
|
||||
}
|
||||
}
|
47
vendor/symfony/process/Symfony/Component/Process/README.md
vendored
Normal file
47
vendor/symfony/process/Symfony/Component/Process/README.md
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
Process Component
|
||||
=================
|
||||
|
||||
Process executes commands in sub-processes.
|
||||
|
||||
In this example, we run a simple directory listing and get the result back:
|
||||
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
$process = new Process('ls -lsa');
|
||||
$process->setTimeout(3600);
|
||||
$process->run();
|
||||
if (!$process->isSuccessful()) {
|
||||
throw new RuntimeException($process->getErrorOutput());
|
||||
}
|
||||
|
||||
print $process->getOutput();
|
||||
|
||||
You can think that this is easy to achieve with plain PHP but it's not especially
|
||||
if you want to take care of the subtle differences between the different platforms.
|
||||
|
||||
And if you want to be able to get some feedback in real-time, just pass an
|
||||
anonymous function to the ``run()`` method and you will get the output buffer
|
||||
as it becomes available:
|
||||
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
$process = new Process('ls -lsa');
|
||||
$process->run(function ($type, $buffer) {
|
||||
if ('err' === $type) {
|
||||
echo 'ERR > '.$buffer;
|
||||
} else {
|
||||
echo 'OUT > '.$buffer;
|
||||
}
|
||||
});
|
||||
|
||||
That's great if you want to execute a long running command (like rsync-ing files to a
|
||||
remote server) and give feedback to the user in real-time.
|
||||
|
||||
Resources
|
||||
---------
|
||||
|
||||
You can run the unit tests with the following command:
|
||||
|
||||
$ cd path/to/Symfony/Component/XXX/
|
||||
$ composer.phar install --dev
|
||||
$ phpunit
|
641
vendor/symfony/process/Symfony/Component/Process/Tests/AbstractProcessTest.php
vendored
Normal file
641
vendor/symfony/process/Symfony/Component/Process/Tests/AbstractProcessTest.php
vendored
Normal file
@@ -0,0 +1,641 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process\Tests;
|
||||
|
||||
use Symfony\Component\Process\Process;
|
||||
use Symfony\Component\Process\Exception\RuntimeException;
|
||||
|
||||
/**
|
||||
* @author Robert Schönthal <seroscho@googlemail.com>
|
||||
*/
|
||||
abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\InvalidArgumentException
|
||||
*/
|
||||
public function testNegativeTimeoutFromConstructor()
|
||||
{
|
||||
$this->getProcess('', null, null, null, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\InvalidArgumentException
|
||||
*/
|
||||
public function testNegativeTimeoutFromSetter()
|
||||
{
|
||||
$p = $this->getProcess('');
|
||||
$p->setTimeout(-1);
|
||||
}
|
||||
|
||||
public function testNullTimeout()
|
||||
{
|
||||
$p = $this->getProcess('');
|
||||
$p->setTimeout(10);
|
||||
$p->setTimeout(null);
|
||||
|
||||
$this->assertNull($p->getTimeout());
|
||||
}
|
||||
|
||||
public function testStopWithTimeoutIsActuallyWorking()
|
||||
{
|
||||
$this->verifyPosixIsEnabled();
|
||||
|
||||
// exec is mandatory here since we send a signal to the process
|
||||
// see https://github.com/symfony/symfony/issues/5030 about prepending
|
||||
// command with exec
|
||||
$p = $this->getProcess('exec php '.__DIR__.'/NonStopableProcess.php 3');
|
||||
$p->start();
|
||||
usleep(100000);
|
||||
$start = microtime(true);
|
||||
$p->stop(1.1, SIGKILL);
|
||||
while ($p->isRunning()) {
|
||||
usleep(1000);
|
||||
}
|
||||
$duration = microtime(true) - $start;
|
||||
|
||||
$this->assertLessThan(1.8, $duration);
|
||||
}
|
||||
|
||||
public function testCallbacksAreExecutedWithStart()
|
||||
{
|
||||
$data = '';
|
||||
|
||||
$process = $this->getProcess('echo "foo";sleep 1;echo "foo"');
|
||||
$process->start(function ($type, $buffer) use (&$data) {
|
||||
$data .= $buffer;
|
||||
});
|
||||
|
||||
$start = microtime(true);
|
||||
while ($process->isRunning()) {
|
||||
usleep(10000);
|
||||
}
|
||||
|
||||
$this->assertEquals("foo\nfoo\n", $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* tests results from sub processes
|
||||
*
|
||||
* @dataProvider responsesCodeProvider
|
||||
*/
|
||||
public function testProcessResponses($expected, $getter, $code)
|
||||
{
|
||||
$p = $this->getProcess(sprintf('php -r %s', escapeshellarg($code)));
|
||||
$p->run();
|
||||
|
||||
$this->assertSame($expected, $p->$getter());
|
||||
}
|
||||
|
||||
/**
|
||||
* tests results from sub processes
|
||||
*
|
||||
* @dataProvider pipesCodeProvider
|
||||
*/
|
||||
public function testProcessPipes($code, $size)
|
||||
{
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->markTestSkipped('Test hangs on Windows & PHP due to https://bugs.php.net/bug.php?id=60120 and https://bugs.php.net/bug.php?id=51800');
|
||||
}
|
||||
|
||||
$expected = str_repeat(str_repeat('*', 1024), $size) . '!';
|
||||
$expectedLength = (1024 * $size) + 1;
|
||||
|
||||
$p = $this->getProcess(sprintf('php -r %s', escapeshellarg($code)));
|
||||
$p->setStdin($expected);
|
||||
$p->run();
|
||||
|
||||
$this->assertEquals($expectedLength, strlen($p->getOutput()));
|
||||
$this->assertEquals($expectedLength, strlen($p->getErrorOutput()));
|
||||
}
|
||||
|
||||
public function chainedCommandsOutputProvider()
|
||||
{
|
||||
return array(
|
||||
array("1\n1\n", ';', '1'),
|
||||
array("2\n2\n", '&&', '2'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @dataProvider chainedCommandsOutputProvider
|
||||
*/
|
||||
public function testChainedCommandsOutput($expected, $operator, $input)
|
||||
{
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->markTestSkipped('Does it work on windows ?');
|
||||
}
|
||||
|
||||
$process = $this->getProcess(sprintf('echo %s %s echo %s', $input, $operator, $input));
|
||||
$process->run();
|
||||
$this->assertEquals($expected, $process->getOutput());
|
||||
}
|
||||
|
||||
public function testCallbackIsExecutedForOutput()
|
||||
{
|
||||
$p = $this->getProcess(sprintf('php -r %s', escapeshellarg('echo \'foo\';')));
|
||||
|
||||
$called = false;
|
||||
$p->run(function ($type, $buffer) use (&$called) {
|
||||
$called = $buffer === 'foo';
|
||||
});
|
||||
|
||||
$this->assertTrue($called, 'The callback should be executed with the output');
|
||||
}
|
||||
|
||||
public function testGetErrorOutput()
|
||||
{
|
||||
$p = new Process(sprintf('php -r %s', escapeshellarg('$n = 0; while ($n < 3) { file_put_contents(\'php://stderr\', \'ERROR\'); $n++; }')));
|
||||
|
||||
$p->run();
|
||||
$this->assertEquals(3, preg_match_all('/ERROR/', $p->getErrorOutput(), $matches));
|
||||
}
|
||||
|
||||
public function testGetIncrementalErrorOutput()
|
||||
{
|
||||
$p = new Process(sprintf('php -r %s', escapeshellarg('$n = 0; while ($n < 3) { usleep(50000); file_put_contents(\'php://stderr\', \'ERROR\'); $n++; }')));
|
||||
|
||||
$p->start();
|
||||
while ($p->isRunning()) {
|
||||
$this->assertLessThanOrEqual(1, preg_match_all('/ERROR/', $p->getIncrementalErrorOutput(), $matches));
|
||||
usleep(20000);
|
||||
}
|
||||
}
|
||||
|
||||
public function testGetOutput()
|
||||
{
|
||||
$p = new Process(sprintf('php -r %s', escapeshellarg('$n=0;while ($n<3) {echo \' foo \';$n++;}')));
|
||||
|
||||
$p->run();
|
||||
$this->assertEquals(3, preg_match_all('/foo/', $p->getOutput(), $matches));
|
||||
}
|
||||
|
||||
public function testGetIncrementalOutput()
|
||||
{
|
||||
$p = new Process(sprintf('php -r %s', escapeshellarg('$n=0;while ($n<3) { echo \' foo \'; usleep(50000); $n++; }')));
|
||||
|
||||
$p->start();
|
||||
while ($p->isRunning()) {
|
||||
$this->assertLessThanOrEqual(1, preg_match_all('/foo/', $p->getIncrementalOutput(), $matches));
|
||||
usleep(20000);
|
||||
}
|
||||
}
|
||||
|
||||
public function testExitCodeCommandFailed()
|
||||
{
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->markTestSkipped('Windows does not support POSIX exit code');
|
||||
}
|
||||
|
||||
// such command run in bash return an exitcode 127
|
||||
$process = $this->getProcess('nonexistingcommandIhopeneversomeonewouldnameacommandlikethis');
|
||||
$process->run();
|
||||
|
||||
$this->assertGreaterThan(0, $process->getExitCode());
|
||||
}
|
||||
|
||||
public function testTTYCommand()
|
||||
{
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->markTestSkipped('Windows does have /dev/tty support');
|
||||
}
|
||||
|
||||
$process = $this->getProcess('echo "foo" >> /dev/null');
|
||||
$process->setTTY(true);
|
||||
$process->run();
|
||||
|
||||
$this->assertSame(Process::STATUS_TERMINATED, $process->getStatus());
|
||||
}
|
||||
|
||||
public function testExitCodeText()
|
||||
{
|
||||
$process = $this->getProcess('');
|
||||
$r = new \ReflectionObject($process);
|
||||
$p = $r->getProperty('exitcode');
|
||||
$p->setAccessible(true);
|
||||
|
||||
$p->setValue($process, 2);
|
||||
$this->assertEquals('Misuse of shell builtins', $process->getExitCodeText());
|
||||
}
|
||||
|
||||
public function testStartIsNonBlocking()
|
||||
{
|
||||
$process = $this->getProcess('php -r "sleep(4);"');
|
||||
$start = microtime(true);
|
||||
$process->start();
|
||||
$end = microtime(true);
|
||||
$this->assertLessThan(1 , $end-$start);
|
||||
}
|
||||
|
||||
public function testUpdateStatus()
|
||||
{
|
||||
$process = $this->getProcess('php -h');
|
||||
$process->run();
|
||||
$this->assertTrue(strlen($process->getOutput()) > 0);
|
||||
}
|
||||
|
||||
public function testGetExitCodeIsNullOnStart()
|
||||
{
|
||||
$process = $this->getProcess('php -r "usleep(200000);"');
|
||||
$this->assertNull($process->getExitCode());
|
||||
$process->start();
|
||||
$this->assertNull($process->getExitCode());
|
||||
$process->wait();
|
||||
$this->assertEquals(0, $process->getExitCode());
|
||||
}
|
||||
|
||||
public function testGetExitCodeIsNullOnWhenStartingAgain()
|
||||
{
|
||||
$process = $this->getProcess('php -r "usleep(200000);"');
|
||||
$process->run();
|
||||
$this->assertEquals(0, $process->getExitCode());
|
||||
$process->start();
|
||||
$this->assertNull($process->getExitCode());
|
||||
$process->wait();
|
||||
$this->assertEquals(0, $process->getExitCode());
|
||||
}
|
||||
|
||||
public function testGetExitCode()
|
||||
{
|
||||
$process = $this->getProcess('php -m');
|
||||
$process->run();
|
||||
$this->assertEquals(0, $process->getExitCode());
|
||||
}
|
||||
|
||||
public function testStatus()
|
||||
{
|
||||
$process = $this->getProcess('php -r "usleep(500000);"');
|
||||
$this->assertFalse($process->isRunning());
|
||||
$this->assertFalse($process->isStarted());
|
||||
$this->assertFalse($process->isTerminated());
|
||||
$this->assertSame(Process::STATUS_READY, $process->getStatus());
|
||||
$process->start();
|
||||
$this->assertTrue($process->isRunning());
|
||||
$this->assertTrue($process->isStarted());
|
||||
$this->assertFalse($process->isTerminated());
|
||||
$this->assertSame(Process::STATUS_STARTED, $process->getStatus());
|
||||
$process->wait();
|
||||
$this->assertFalse($process->isRunning());
|
||||
$this->assertTrue($process->isStarted());
|
||||
$this->assertTrue($process->isTerminated());
|
||||
$this->assertSame(Process::STATUS_TERMINATED, $process->getStatus());
|
||||
}
|
||||
|
||||
public function testStop()
|
||||
{
|
||||
$process = $this->getProcess('php -r "sleep(4);"');
|
||||
$process->start();
|
||||
$this->assertTrue($process->isRunning());
|
||||
$process->stop();
|
||||
$this->assertFalse($process->isRunning());
|
||||
}
|
||||
|
||||
public function testIsSuccessful()
|
||||
{
|
||||
$process = $this->getProcess('php -m');
|
||||
$process->run();
|
||||
$this->assertTrue($process->isSuccessful());
|
||||
}
|
||||
|
||||
public function testIsSuccessfulOnlyAfterTerminated()
|
||||
{
|
||||
$process = $this->getProcess('sleep 1');
|
||||
$process->start();
|
||||
while ($process->isRunning()) {
|
||||
$this->assertFalse($process->isSuccessful());
|
||||
usleep(300000);
|
||||
}
|
||||
|
||||
$this->assertTrue($process->isSuccessful());
|
||||
}
|
||||
|
||||
public function testIsNotSuccessful()
|
||||
{
|
||||
$process = $this->getProcess('php -r "sleep(4);"');
|
||||
$process->start();
|
||||
$this->assertTrue($process->isRunning());
|
||||
$process->stop();
|
||||
$this->assertFalse($process->isSuccessful());
|
||||
}
|
||||
|
||||
public function testProcessIsNotSignaled()
|
||||
{
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->markTestSkipped('Windows does not support POSIX signals');
|
||||
}
|
||||
|
||||
$process = $this->getProcess('php -m');
|
||||
$process->run();
|
||||
$this->assertFalse($process->hasBeenSignaled());
|
||||
}
|
||||
|
||||
public function testProcessWithoutTermSignalIsNotSignaled()
|
||||
{
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->markTestSkipped('Windows does not support POSIX signals');
|
||||
}
|
||||
|
||||
$process = $this->getProcess('php -m');
|
||||
$process->run();
|
||||
$this->assertFalse($process->hasBeenSignaled());
|
||||
}
|
||||
|
||||
public function testProcessWithoutTermSignal()
|
||||
{
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->markTestSkipped('Windows does not support POSIX signals');
|
||||
}
|
||||
|
||||
$process = $this->getProcess('php -m');
|
||||
$process->run();
|
||||
$this->assertEquals(0, $process->getTermSignal());
|
||||
}
|
||||
|
||||
public function testProcessIsSignaledIfStopped()
|
||||
{
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->markTestSkipped('Windows does not support POSIX signals');
|
||||
}
|
||||
|
||||
$process = $this->getProcess('php -r "sleep(4);"');
|
||||
$process->start();
|
||||
$process->stop();
|
||||
$this->assertTrue($process->hasBeenSignaled());
|
||||
}
|
||||
|
||||
public function testProcessWithTermSignal()
|
||||
{
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->markTestSkipped('Windows does not support POSIX signals');
|
||||
}
|
||||
|
||||
// SIGTERM is only defined if pcntl extension is present
|
||||
$termSignal = defined('SIGTERM') ? SIGTERM : 15;
|
||||
|
||||
$process = $this->getProcess('php -r "sleep(4);"');
|
||||
$process->start();
|
||||
$process->stop();
|
||||
|
||||
$this->assertEquals($termSignal, $process->getTermSignal());
|
||||
}
|
||||
|
||||
public function testProcessThrowsExceptionWhenExternallySignaled()
|
||||
{
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->markTestSkipped('Windows does not support POSIX signals');
|
||||
}
|
||||
|
||||
if (!function_exists('posix_kill')) {
|
||||
$this->markTestSkipped('posix_kill is required for this test');
|
||||
}
|
||||
|
||||
$termSignal = defined('SIGKILL') ? SIGKILL : 9;
|
||||
|
||||
$process = $this->getProcess('exec php -r "while (true) {}"');
|
||||
$process->start();
|
||||
posix_kill($process->getPid(), $termSignal);
|
||||
|
||||
$this->setExpectedException('Symfony\Component\Process\Exception\RuntimeException', 'The process has been signaled with signal "9".');
|
||||
$process->wait();
|
||||
}
|
||||
|
||||
public function testRestart()
|
||||
{
|
||||
$process1 = $this->getProcess('php -r "echo getmypid();"');
|
||||
$process1->run();
|
||||
$process2 = $process1->restart();
|
||||
|
||||
usleep(300000); // wait for output
|
||||
|
||||
// Ensure that both processed finished and the output is numeric
|
||||
$this->assertFalse($process1->isRunning());
|
||||
$this->assertFalse($process2->isRunning());
|
||||
$this->assertTrue(is_numeric($process1->getOutput()));
|
||||
$this->assertTrue(is_numeric($process2->getOutput()));
|
||||
|
||||
// Ensure that restart returned a new process by check that the output is different
|
||||
$this->assertNotEquals($process1->getOutput(), $process2->getOutput());
|
||||
}
|
||||
|
||||
public function testPhpDeadlock()
|
||||
{
|
||||
$this->markTestSkipped('Can course php to hang');
|
||||
|
||||
// Sleep doesn't work as it will allow the process to handle signals and close
|
||||
// file handles from the other end.
|
||||
$process = $this->getProcess('php -r "while (true) {}"');
|
||||
$process->start();
|
||||
|
||||
// PHP will deadlock when it tries to cleanup $process
|
||||
}
|
||||
|
||||
public function testRunProcessWithTimeout()
|
||||
{
|
||||
$timeout = 0.5;
|
||||
$process = $this->getProcess('sleep 3');
|
||||
$process->setTimeout($timeout);
|
||||
$start = microtime(true);
|
||||
try {
|
||||
$process->run();
|
||||
$this->fail('A RuntimeException should have been raised');
|
||||
} catch (RuntimeException $e) {
|
||||
|
||||
}
|
||||
$duration = microtime(true) - $start;
|
||||
|
||||
$this->assertLessThan($timeout + Process::TIMEOUT_PRECISION, $duration);
|
||||
}
|
||||
|
||||
public function testCheckTimeoutOnStartedProcess()
|
||||
{
|
||||
$timeout = 0.5;
|
||||
$precision = 100000;
|
||||
$process = $this->getProcess('sleep 3');
|
||||
$process->setTimeout($timeout);
|
||||
$start = microtime(true);
|
||||
|
||||
$process->start();
|
||||
|
||||
try {
|
||||
while ($process->isRunning()) {
|
||||
$process->checkTimeout();
|
||||
usleep($precision);
|
||||
}
|
||||
$this->fail('A RuntimeException should have been raised');
|
||||
} catch (RuntimeException $e) {
|
||||
|
||||
}
|
||||
$duration = microtime(true) - $start;
|
||||
|
||||
$this->assertLessThan($timeout + $precision, $duration);
|
||||
$this->assertFalse($process->isSuccessful());
|
||||
}
|
||||
|
||||
public function testGetPid()
|
||||
{
|
||||
$process = $this->getProcess('php -r "sleep(1);"');
|
||||
$process->start();
|
||||
$this->assertGreaterThan(0, $process->getPid());
|
||||
$process->stop();
|
||||
}
|
||||
|
||||
public function testGetPidIsNullBeforeStart()
|
||||
{
|
||||
$process = $this->getProcess('php -r "sleep(1);"');
|
||||
$this->assertNull($process->getPid());
|
||||
}
|
||||
|
||||
public function testGetPidIsNullAfterRun()
|
||||
{
|
||||
$process = $this->getProcess('php -m');
|
||||
$process->run();
|
||||
$this->assertNull($process->getPid());
|
||||
}
|
||||
|
||||
public function testSignal()
|
||||
{
|
||||
$this->verifyPosixIsEnabled();
|
||||
|
||||
$process = $this->getProcess('exec php -f ' . __DIR__ . '/SignalListener.php');
|
||||
$process->start();
|
||||
usleep(500000);
|
||||
$process->signal(SIGUSR1);
|
||||
|
||||
while ($process->isRunning() && false === strpos($process->getoutput(), 'Caught SIGUSR1')) {
|
||||
usleep(10000);
|
||||
}
|
||||
|
||||
$this->assertEquals('Caught SIGUSR1', $process->getOutput());
|
||||
}
|
||||
|
||||
public function testExitCodeIsAvailableAfterSignal()
|
||||
{
|
||||
$this->verifyPosixIsEnabled();
|
||||
|
||||
$process = $this->getProcess('sleep 4');
|
||||
$process->start();
|
||||
$process->signal(SIGKILL);
|
||||
|
||||
while ($process->isRunning()) {
|
||||
usleep(10000);
|
||||
}
|
||||
|
||||
$this->assertFalse($process->isRunning());
|
||||
$this->assertTrue($process->hasBeenSignaled());
|
||||
$this->assertFalse($process->isSuccessful());
|
||||
$this->assertEquals(137, $process->getExitCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Process\Exception\LogicException
|
||||
*/
|
||||
public function testSignalProcessNotRunning()
|
||||
{
|
||||
$this->verifyPosixIsEnabled();
|
||||
$process = $this->getProcess('php -m');
|
||||
$process->signal(SIGHUP);
|
||||
}
|
||||
|
||||
private function verifyPosixIsEnabled()
|
||||
{
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->markTestSkipped('POSIX signals do not work on windows');
|
||||
}
|
||||
if (!defined('SIGUSR1')) {
|
||||
$this->markTestSkipped('The pcntl extension is not enabled');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testSignalWithWrongIntSignal()
|
||||
{
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->markTestSkipped('POSIX signals do not work on windows');
|
||||
}
|
||||
|
||||
$process = $this->getProcess('php -r "sleep(3);"');
|
||||
$process->start();
|
||||
$process->signal(-4);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testSignalWithWrongNonIntSignal()
|
||||
{
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->markTestSkipped('POSIX signals do not work on windows');
|
||||
}
|
||||
|
||||
$process = $this->getProcess('php -r "sleep(3);"');
|
||||
$process->start();
|
||||
$process->signal('Céphalopodes');
|
||||
}
|
||||
|
||||
public function responsesCodeProvider()
|
||||
{
|
||||
return array(
|
||||
//expected output / getter / code to execute
|
||||
//array(1,'getExitCode','exit(1);'),
|
||||
//array(true,'isSuccessful','exit();'),
|
||||
array('output', 'getOutput', 'echo \'output\';'),
|
||||
);
|
||||
}
|
||||
|
||||
public function pipesCodeProvider()
|
||||
{
|
||||
$variations = array(
|
||||
'fwrite(STDOUT, $in = file_get_contents(\'php://stdin\')); fwrite(STDERR, $in);',
|
||||
'include \''.__DIR__.'/ProcessTestHelper.php\';',
|
||||
);
|
||||
|
||||
$codes = array();
|
||||
foreach (array(1, 16, 64, 1024, 4096) as $size) {
|
||||
foreach ($variations as $code) {
|
||||
$codes[] = array($code, $size);
|
||||
}
|
||||
}
|
||||
|
||||
return $codes;
|
||||
}
|
||||
|
||||
/**
|
||||
* provides default method names for simple getter/setter
|
||||
*/
|
||||
public function methodProvider()
|
||||
{
|
||||
$defaults = array(
|
||||
array('CommandLine'),
|
||||
array('Timeout'),
|
||||
array('WorkingDirectory'),
|
||||
array('Env'),
|
||||
array('Stdin'),
|
||||
array('Options')
|
||||
);
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $commandline
|
||||
* @param null $cwd
|
||||
* @param array $env
|
||||
* @param null $stdin
|
||||
* @param integer $timeout
|
||||
* @param array $options
|
||||
*
|
||||
* @return Process
|
||||
*/
|
||||
abstract protected function getProcess($commandline, $cwd = null, array $env = null, $stdin = null, $timeout = 60, array $options = array());
|
||||
}
|
37
vendor/symfony/process/Symfony/Component/Process/Tests/NonStopableProcess.php
vendored
Normal file
37
vendor/symfony/process/Symfony/Component/Process/Tests/NonStopableProcess.php
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Runs a PHP script that can be stopped only with a SIGKILL (9) signal for 3 seconds
|
||||
*
|
||||
* @args duration Run this script with a custom duration
|
||||
*
|
||||
* @example `php NonStopableProcess.php 42` will run the script for 42 seconds
|
||||
*/
|
||||
|
||||
function handleSignal($signal)
|
||||
{
|
||||
switch ($signal) {
|
||||
case SIGTERM:
|
||||
$name = 'SIGTERM';
|
||||
break;
|
||||
case SIGINT:
|
||||
$name = 'SIGINT';
|
||||
break;
|
||||
default:
|
||||
$name = $signal . ' (unknown)';
|
||||
break;
|
||||
}
|
||||
|
||||
echo "received signal $name\n";
|
||||
}
|
||||
|
||||
declare(ticks=1);
|
||||
pcntl_signal(SIGTERM, 'handleSignal');
|
||||
pcntl_signal(SIGINT, 'handleSignal');
|
||||
|
||||
$duration = isset($argv[1]) ? (int) $argv[1] : 3;
|
||||
$start = microtime(true);
|
||||
|
||||
while ($duration > (microtime(true) - $start)) {
|
||||
usleep(1000);
|
||||
}
|
64
vendor/symfony/process/Symfony/Component/Process/Tests/PhpExecutableFinderTest.php
vendored
Normal file
64
vendor/symfony/process/Symfony/Component/Process/Tests/PhpExecutableFinderTest.php
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process\Tests;
|
||||
|
||||
use Symfony\Component\Process\PhpExecutableFinder;
|
||||
|
||||
/**
|
||||
* @author Robert Schönthal <seroscho@googlemail.com>
|
||||
*/
|
||||
class PhpExecutableFinderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* tests find() with the env var PHP_PATH
|
||||
*/
|
||||
public function testFindWithPhpPath()
|
||||
{
|
||||
if (defined('PHP_BINARY')) {
|
||||
$this->markTestSkipped('The PHP binary is easily available as of PHP 5.4');
|
||||
}
|
||||
|
||||
$f = new PhpExecutableFinder();
|
||||
|
||||
$current = $f->find();
|
||||
|
||||
//not executable PHP_PATH
|
||||
putenv('PHP_PATH=/not/executable/php');
|
||||
$this->assertFalse($f->find(), '::find() returns false for not executable php');
|
||||
|
||||
//executable PHP_PATH
|
||||
putenv('PHP_PATH='.$current);
|
||||
$this->assertEquals($f->find(), $current, '::find() returns the executable php');
|
||||
}
|
||||
|
||||
/**
|
||||
* tests find() with default executable
|
||||
*/
|
||||
public function testFindWithSuffix()
|
||||
{
|
||||
if (defined('PHP_BINARY')) {
|
||||
$this->markTestSkipped('The PHP binary is easily available as of PHP 5.4');
|
||||
}
|
||||
|
||||
putenv('PHP_PATH=');
|
||||
putenv('PHP_PEAR_PHP_BIN=');
|
||||
$f = new PhpExecutableFinder();
|
||||
|
||||
$current = $f->find();
|
||||
|
||||
//TODO maybe php executable is custom or even windows
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->assertTrue(is_executable($current));
|
||||
$this->assertTrue((bool) preg_match('/'.addSlashes(DIRECTORY_SEPARATOR).'php\.(exe|bat|cmd|com)$/i', $current), '::find() returns the executable php with suffixes');
|
||||
}
|
||||
}
|
||||
}
|
29
vendor/symfony/process/Symfony/Component/Process/Tests/PhpProcessTest.php
vendored
Normal file
29
vendor/symfony/process/Symfony/Component/Process/Tests/PhpProcessTest.php
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process\Tests;
|
||||
|
||||
use Symfony\Component\Process\PhpProcess;
|
||||
|
||||
class PhpProcessTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testNonBlockingWorks()
|
||||
{
|
||||
$expected = 'hello world!';
|
||||
$process = new PhpProcess(<<<PHP
|
||||
<?php echo '$expected';
|
||||
PHP
|
||||
);
|
||||
$process->start();
|
||||
$process->wait();
|
||||
$this->assertEquals($expected, $process->getOutput());
|
||||
}
|
||||
}
|
200
vendor/symfony/process/Symfony/Component/Process/Tests/ProcessBuilderTest.php
vendored
Normal file
200
vendor/symfony/process/Symfony/Component/Process/Tests/ProcessBuilderTest.php
vendored
Normal file
@@ -0,0 +1,200 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process\Tests;
|
||||
|
||||
use Symfony\Component\Process\ProcessBuilder;
|
||||
|
||||
class ProcessBuilderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testInheritEnvironmentVars()
|
||||
{
|
||||
$snapshot = $_ENV;
|
||||
$_ENV = $expected = array('foo' => 'bar');
|
||||
|
||||
$pb = new ProcessBuilder();
|
||||
$pb->add('foo')->inheritEnvironmentVariables();
|
||||
$proc = $pb->getProcess();
|
||||
|
||||
$this->assertNull($proc->getEnv(), '->inheritEnvironmentVariables() copies $_ENV');
|
||||
|
||||
$_ENV = $snapshot;
|
||||
}
|
||||
|
||||
public function testProcessShouldInheritAndOverrideEnvironmentVars()
|
||||
{
|
||||
$snapshot = $_ENV;
|
||||
$_ENV = array('foo' => 'bar', 'bar' => 'baz');
|
||||
$expected = array('foo' => 'foo', 'bar' => 'baz');
|
||||
|
||||
$pb = new ProcessBuilder();
|
||||
$pb->add('foo')->inheritEnvironmentVariables()
|
||||
->setEnv('foo', 'foo');
|
||||
$proc = $pb->getProcess();
|
||||
|
||||
$this->assertEquals($expected, $proc->getEnv(), '->inheritEnvironmentVariables() copies $_ENV');
|
||||
|
||||
$_ENV = $snapshot;
|
||||
}
|
||||
|
||||
public function testProcessBuilderShouldNotPassEnvArrays()
|
||||
{
|
||||
$snapshot = $_ENV;
|
||||
$_ENV = array('a' => array('b', 'c'), 'd' => 'e', 'f' => 'g');
|
||||
$expected = array('d' => 'e', 'f' => 'g');
|
||||
|
||||
$pb = new ProcessBuilder();
|
||||
$pb->add('a')->inheritEnvironmentVariables()
|
||||
->setEnv('d', 'e');
|
||||
$proc = $pb->getProcess();
|
||||
|
||||
$this->assertEquals($expected, $proc->getEnv(), '->inheritEnvironmentVariables() removes array values from $_ENV');
|
||||
|
||||
$_ENV = $snapshot;
|
||||
}
|
||||
|
||||
public function testInheritEnvironmentVarsByDefault()
|
||||
{
|
||||
$pb = new ProcessBuilder();
|
||||
$proc = $pb->add('foo')->getProcess();
|
||||
|
||||
$this->assertNull($proc->getEnv());
|
||||
}
|
||||
|
||||
public function testNotReplaceExplicitlySetVars()
|
||||
{
|
||||
$snapshot = $_ENV;
|
||||
$_ENV = array('foo' => 'bar');
|
||||
$expected = array('foo' => 'baz');
|
||||
|
||||
$pb = new ProcessBuilder();
|
||||
$pb
|
||||
->setEnv('foo', 'baz')
|
||||
->inheritEnvironmentVariables()
|
||||
->add('foo')
|
||||
;
|
||||
$proc = $pb->getProcess();
|
||||
|
||||
$this->assertEquals($expected, $proc->getEnv(), '->inheritEnvironmentVariables() copies $_ENV');
|
||||
|
||||
$_ENV = $snapshot;
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\InvalidArgumentException
|
||||
*/
|
||||
public function testNegativeTimeoutFromSetter()
|
||||
{
|
||||
$pb = new ProcessBuilder();
|
||||
$pb->setTimeout(-1);
|
||||
}
|
||||
|
||||
public function testNullTimeout()
|
||||
{
|
||||
$pb = new ProcessBuilder();
|
||||
$pb->setTimeout(10);
|
||||
$pb->setTimeout(null);
|
||||
|
||||
$r = new \ReflectionObject($pb);
|
||||
$p = $r->getProperty('timeout');
|
||||
$p->setAccessible(true);
|
||||
|
||||
$this->assertNull($p->getValue($pb));
|
||||
}
|
||||
|
||||
public function testShouldSetArguments()
|
||||
{
|
||||
$pb = new ProcessBuilder(array('initial'));
|
||||
$pb->setArguments(array('second'));
|
||||
|
||||
$proc = $pb->getProcess();
|
||||
|
||||
$this->assertContains("second", $proc->getCommandLine());
|
||||
}
|
||||
|
||||
public function testPrefixIsPrependedToAllGeneratedProcess()
|
||||
{
|
||||
$pb = new ProcessBuilder();
|
||||
$pb->setPrefix('/usr/bin/php');
|
||||
|
||||
$proc = $pb->setArguments(array('-v'))->getProcess();
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->assertEquals('"/usr/bin/php" "-v"', $proc->getCommandLine());
|
||||
} else {
|
||||
$this->assertEquals("'/usr/bin/php' '-v'", $proc->getCommandLine());
|
||||
}
|
||||
|
||||
$proc = $pb->setArguments(array('-i'))->getProcess();
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->assertEquals('"/usr/bin/php" "-i"', $proc->getCommandLine());
|
||||
} else {
|
||||
$this->assertEquals("'/usr/bin/php' '-i'", $proc->getCommandLine());
|
||||
}
|
||||
}
|
||||
|
||||
public function testShouldEscapeArguments()
|
||||
{
|
||||
$pb = new ProcessBuilder(array('%path%', 'foo " bar'));
|
||||
$proc = $pb->getProcess();
|
||||
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->assertSame('^%"path"^% "foo "\\"" bar"', $proc->getCommandLine());
|
||||
} else {
|
||||
$this->assertSame("'%path%' 'foo \" bar'", $proc->getCommandLine());
|
||||
}
|
||||
}
|
||||
|
||||
public function testShouldEscapeArgumentsAndPrefix()
|
||||
{
|
||||
$pb = new ProcessBuilder(array('arg'));
|
||||
$pb->setPrefix('%prefix%');
|
||||
$proc = $pb->getProcess();
|
||||
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->assertSame('^%"prefix"^% "arg"', $proc->getCommandLine());
|
||||
} else {
|
||||
$this->assertSame("'%prefix%' 'arg'", $proc->getCommandLine());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\LogicException
|
||||
*/
|
||||
public function testShouldThrowALogicExceptionIfNoPrefixAndNoArgument()
|
||||
{
|
||||
ProcessBuilder::create()->getProcess();
|
||||
}
|
||||
|
||||
public function testShouldNotThrowALogicExceptionIfNoArgument()
|
||||
{
|
||||
$process = ProcessBuilder::create()
|
||||
->setPrefix('/usr/bin/php')
|
||||
->getProcess();
|
||||
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->assertEquals('"/usr/bin/php"', $process->getCommandLine());
|
||||
} else {
|
||||
$this->assertEquals("'/usr/bin/php'", $process->getCommandLine());
|
||||
}
|
||||
}
|
||||
|
||||
public function testShouldNotThrowALogicExceptionIfNoPrefix()
|
||||
{
|
||||
$process = ProcessBuilder::create(array('/usr/bin/php'))
|
||||
->getProcess();
|
||||
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->assertEquals('"/usr/bin/php"', $process->getCommandLine());
|
||||
} else {
|
||||
$this->assertEquals("'/usr/bin/php'", $process->getCommandLine());
|
||||
}
|
||||
}
|
||||
}
|
83
vendor/symfony/process/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php
vendored
Normal file
83
vendor/symfony/process/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process\Tests;
|
||||
|
||||
use Symfony\Component\Process\Exception\ProcessFailedException;
|
||||
|
||||
/**
|
||||
* @author Sebastian Marek <proofek@gmail.com>
|
||||
*/
|
||||
class ProcessFailedExceptionTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* tests ProcessFailedException throws exception if the process was successful
|
||||
*/
|
||||
public function testProcessFailedExceptionThrowsException()
|
||||
{
|
||||
$process = $this->getMock(
|
||||
'Symfony\Component\Process\Process',
|
||||
array('isSuccessful'),
|
||||
array('php')
|
||||
);
|
||||
$process->expects($this->once())
|
||||
->method('isSuccessful')
|
||||
->will($this->returnValue(true));
|
||||
|
||||
$this->setExpectedException(
|
||||
'\InvalidArgumentException',
|
||||
'Expected a failed process, but the given process was successful.'
|
||||
);
|
||||
|
||||
new ProcessFailedException($process);
|
||||
}
|
||||
|
||||
/**
|
||||
* tests ProcessFailedException uses information from process output
|
||||
* to generate exception message
|
||||
*/
|
||||
public function testProcessFailedExceptionPopulatesInformationFromProcessOutput()
|
||||
{
|
||||
$cmd = 'php';
|
||||
$exitCode = 1;
|
||||
$exitText = 'General error';
|
||||
$output = "Command output";
|
||||
$errorOutput = "FATAL: Unexpected error";
|
||||
|
||||
$process = $this->getMock(
|
||||
'Symfony\Component\Process\Process',
|
||||
array('isSuccessful', 'getOutput', 'getErrorOutput', 'getExitCode', 'getExitCodeText'),
|
||||
array($cmd)
|
||||
);
|
||||
$process->expects($this->once())
|
||||
->method('isSuccessful')
|
||||
->will($this->returnValue(false));
|
||||
$process->expects($this->once())
|
||||
->method('getOutput')
|
||||
->will($this->returnValue($output));
|
||||
$process->expects($this->once())
|
||||
->method('getErrorOutput')
|
||||
->will($this->returnValue($errorOutput));
|
||||
$process->expects($this->once())
|
||||
->method('getExitCode')
|
||||
->will($this->returnValue($exitCode));
|
||||
$process->expects($this->once())
|
||||
->method('getExitCodeText')
|
||||
->will($this->returnValue($exitText));
|
||||
|
||||
$exception = new ProcessFailedException($process);
|
||||
|
||||
$this->assertEquals(
|
||||
"The command \"$cmd\" failed.\nExit Code: $exitCode($exitText)\n\nOutput:\n================\n{$output}\n\nError Output:\n================\n{$errorOutput}",
|
||||
$exception->getMessage()
|
||||
);
|
||||
}
|
||||
}
|
22
vendor/symfony/process/Symfony/Component/Process/Tests/ProcessInSigchildEnvironment.php
vendored
Normal file
22
vendor/symfony/process/Symfony/Component/Process/Tests/ProcessInSigchildEnvironment.php
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process\Tests;
|
||||
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
class ProcessInSigchildEnvironment extends Process
|
||||
{
|
||||
protected function isSigchildEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
63
vendor/symfony/process/Symfony/Component/Process/Tests/ProcessTestHelper.php
vendored
Normal file
63
vendor/symfony/process/Symfony/Component/Process/Tests/ProcessTestHelper.php
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
define('ERR_SELECT_FAILED', 1);
|
||||
define('ERR_TIMEOUT', 2);
|
||||
define('ERR_READ_FAILED', 3);
|
||||
define('ERR_WRITE_FAILED', 4);
|
||||
|
||||
$read = array(STDIN);
|
||||
$write = array(STDOUT, STDERR);
|
||||
|
||||
stream_set_blocking(STDIN, false);
|
||||
stream_set_blocking(STDOUT, false);
|
||||
stream_set_blocking(STDERR, false);
|
||||
|
||||
$out = $err = '';
|
||||
while ($read || $write) {
|
||||
$r = $read;
|
||||
$w = $write;
|
||||
$e = null;
|
||||
$n = stream_select($r, $w, $e, 5);
|
||||
|
||||
if (false === $n) {
|
||||
die(ERR_SELECT_FAILED);
|
||||
} elseif ($n < 1) {
|
||||
die(ERR_TIMEOUT);
|
||||
}
|
||||
|
||||
if (in_array(STDOUT, $w) && strlen($out) > 0) {
|
||||
$written = fwrite(STDOUT, (binary) $out, 1024);
|
||||
if (false === $written) {
|
||||
die(ERR_WRITE_FAILED);
|
||||
}
|
||||
$out = (binary) substr($out, $written);
|
||||
}
|
||||
if (null === $read && strlen($out) < 1) {
|
||||
$write = array_diff($write, array(STDOUT));
|
||||
}
|
||||
|
||||
if (in_array(STDERR, $w) && strlen($err) > 0) {
|
||||
$written = fwrite(STDERR, (binary) $err, 1024);
|
||||
if (false === $written) {
|
||||
die(ERR_WRITE_FAILED);
|
||||
}
|
||||
$err = (binary) substr($err, $written);
|
||||
}
|
||||
if (null === $read && strlen($err) < 1) {
|
||||
$write = array_diff($write, array(STDERR));
|
||||
}
|
||||
|
||||
if ($r) {
|
||||
$str = fread(STDIN, 1024);
|
||||
if (false !== $str) {
|
||||
$out .= $str;
|
||||
$err .= $str;
|
||||
}
|
||||
if (false === $str || feof(STDIN)) {
|
||||
$read = null;
|
||||
if (!feof(STDIN)) {
|
||||
die(ERR_READ_FAILED);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
44
vendor/symfony/process/Symfony/Component/Process/Tests/ProcessUtilsTest.php
vendored
Normal file
44
vendor/symfony/process/Symfony/Component/Process/Tests/ProcessUtilsTest.php
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process\Tests;
|
||||
|
||||
use Symfony\Component\Process\ProcessUtils;
|
||||
|
||||
class ProcessUtilsTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider dataArguments
|
||||
*/
|
||||
public function testEscapeArgument($result, $argument)
|
||||
{
|
||||
$this->assertSame($result, ProcessUtils::escapeArgument($argument));
|
||||
}
|
||||
|
||||
public function dataArguments()
|
||||
{
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
return array(
|
||||
array('"foo bar"', 'foo bar'),
|
||||
array('^%"path"^%', '%path%'),
|
||||
array('"<|>"\\"" "\\""\'f"', '<|>" "\'f'),
|
||||
array('""', ''),
|
||||
);
|
||||
}
|
||||
|
||||
return array(
|
||||
array("'foo bar'", 'foo bar'),
|
||||
array("'%path%'", '%path%'),
|
||||
array("'<|>\" \"'\\''f'", '<|>" "\'f'),
|
||||
array("''", ''),
|
||||
);
|
||||
}
|
||||
}
|
188
vendor/symfony/process/Symfony/Component/Process/Tests/SigchildDisabledProcessTest.php
vendored
Normal file
188
vendor/symfony/process/Symfony/Component/Process/Tests/SigchildDisabledProcessTest.php
vendored
Normal file
@@ -0,0 +1,188 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process\Tests;
|
||||
|
||||
class SigchildDisabledProcessTest extends AbstractProcessTest
|
||||
{
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testGetExitCode()
|
||||
{
|
||||
parent::testGetExitCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testGetExitCodeIsNullOnStart()
|
||||
{
|
||||
parent::testGetExitCodeIsNullOnStart();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testGetExitCodeIsNullOnWhenStartingAgain()
|
||||
{
|
||||
parent::testGetExitCodeIsNullOnWhenStartingAgain();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testExitCodeCommandFailed()
|
||||
{
|
||||
parent::testExitCodeCommandFailed();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testProcessIsSignaledIfStopped()
|
||||
{
|
||||
parent::testProcessIsSignaledIfStopped();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testProcessWithTermSignal()
|
||||
{
|
||||
parent::testProcessWithTermSignal();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testProcessIsNotSignaled()
|
||||
{
|
||||
parent::testProcessIsNotSignaled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testProcessWithoutTermSignal()
|
||||
{
|
||||
parent::testProcessWithoutTermSignal();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testCheckTimeoutOnStartedProcess()
|
||||
{
|
||||
parent::testCheckTimeoutOnStartedProcess();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testGetPid()
|
||||
{
|
||||
parent::testGetPid();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testGetPidIsNullBeforeStart()
|
||||
{
|
||||
parent::testGetPidIsNullBeforeStart();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testGetPidIsNullAfterRun()
|
||||
{
|
||||
parent::testGetPidIsNullAfterRun();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testExitCodeText()
|
||||
{
|
||||
$process = $this->getProcess('qdfsmfkqsdfmqmsd');
|
||||
$process->run();
|
||||
|
||||
$process->getExitCodeText();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testIsSuccessful()
|
||||
{
|
||||
parent::testIsSuccessful();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testIsSuccessfulOnlyAfterTerminated()
|
||||
{
|
||||
parent::testIsSuccessfulOnlyAfterTerminated();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testIsNotSuccessful()
|
||||
{
|
||||
parent::testIsNotSuccessful();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testSignal()
|
||||
{
|
||||
parent::testSignal();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testProcessWithoutTermSignalIsNotSignaled()
|
||||
{
|
||||
parent::testProcessWithoutTermSignalIsNotSignaled();
|
||||
}
|
||||
|
||||
public function testStopWithTimeoutIsActuallyWorking()
|
||||
{
|
||||
$this->markTestSkipped('Stopping with signal is not supported in sigchild environment');
|
||||
}
|
||||
|
||||
public function testProcessThrowsExceptionWhenExternallySignaled()
|
||||
{
|
||||
$this->markTestSkipped('Retrieving Pid is not supported in sigchild environment');
|
||||
}
|
||||
|
||||
public function testExitCodeIsAvailableAfterSignal()
|
||||
{
|
||||
$this->markTestSkipped('Signal is not supported in sigchild environment');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getProcess($commandline, $cwd = null, array $env = null, $stdin = null, $timeout = 60, array $options = array())
|
||||
{
|
||||
$process = new ProcessInSigchildEnvironment($commandline, $cwd, $env, $stdin, $timeout, $options);
|
||||
$process->setEnhanceSigchildCompatibility(false);
|
||||
|
||||
return $process;
|
||||
}
|
||||
}
|
116
vendor/symfony/process/Symfony/Component/Process/Tests/SigchildEnabledProcessTest.php
vendored
Normal file
116
vendor/symfony/process/Symfony/Component/Process/Tests/SigchildEnabledProcessTest.php
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process\Tests;
|
||||
|
||||
class SigchildEnabledProcessTest extends AbstractProcessTest
|
||||
{
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testProcessIsSignaledIfStopped()
|
||||
{
|
||||
parent::testProcessIsSignaledIfStopped();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testProcessWithTermSignal()
|
||||
{
|
||||
parent::testProcessWithTermSignal();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testProcessIsNotSignaled()
|
||||
{
|
||||
parent::testProcessIsNotSignaled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testProcessWithoutTermSignal()
|
||||
{
|
||||
parent::testProcessWithoutTermSignal();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testGetPid()
|
||||
{
|
||||
parent::testGetPid();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testGetPidIsNullBeforeStart()
|
||||
{
|
||||
parent::testGetPidIsNullBeforeStart();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testGetPidIsNullAfterRun()
|
||||
{
|
||||
parent::testGetPidIsNullAfterRun();
|
||||
}
|
||||
|
||||
public function testExitCodeText()
|
||||
{
|
||||
$process = $this->getProcess('qdfsmfkqsdfmqmsd');
|
||||
$process->run();
|
||||
|
||||
$this->assertInternalType('string', $process->getExitCodeText());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testSignal()
|
||||
{
|
||||
parent::testSignal();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testProcessWithoutTermSignalIsNotSignaled()
|
||||
{
|
||||
parent::testProcessWithoutTermSignalIsNotSignaled();
|
||||
}
|
||||
|
||||
public function testProcessThrowsExceptionWhenExternallySignaled()
|
||||
{
|
||||
$this->markTestSkipped('Retrieving Pid is not supported in sigchild environment');
|
||||
}
|
||||
|
||||
public function testExitCodeIsAvailableAfterSignal()
|
||||
{
|
||||
$this->markTestSkipped('Signal is not supported in sigchild environment');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getProcess($commandline, $cwd = null, array $env = null, $stdin = null, $timeout = 60, array $options = array())
|
||||
{
|
||||
$process = new ProcessInSigchildEnvironment($commandline, $cwd, $env, $stdin, $timeout, $options);
|
||||
$process->setEnhanceSigchildCompatibility(true);
|
||||
|
||||
return $process;
|
||||
}
|
||||
}
|
16
vendor/symfony/process/Symfony/Component/Process/Tests/SignalListener.php
vendored
Normal file
16
vendor/symfony/process/Symfony/Component/Process/Tests/SignalListener.php
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
// required for signal handling
|
||||
declare(ticks = 1);
|
||||
|
||||
pcntl_signal(SIGUSR1, function(){echo "Caught SIGUSR1"; exit;});
|
||||
|
||||
$n=0;
|
||||
|
||||
// ticks require activity to work - sleep(4); does not work
|
||||
while ($n < 400) {
|
||||
usleep(10000);
|
||||
$n++;
|
||||
}
|
||||
|
||||
return;
|
147
vendor/symfony/process/Symfony/Component/Process/Tests/SimpleProcessTest.php
vendored
Normal file
147
vendor/symfony/process/Symfony/Component/Process/Tests/SimpleProcessTest.php
vendored
Normal file
@@ -0,0 +1,147 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Process\Tests;
|
||||
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
class SimpleProcessTest extends AbstractProcessTest
|
||||
{
|
||||
private $enabledSigchild = false;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
ob_start();
|
||||
phpinfo(INFO_GENERAL);
|
||||
|
||||
$this->enabledSigchild = false !== strpos(ob_get_clean(), '--enable-sigchild');
|
||||
}
|
||||
|
||||
public function testGetExitCode()
|
||||
{
|
||||
$this->skipIfPHPSigchild();
|
||||
parent::testGetExitCode();
|
||||
}
|
||||
|
||||
public function testExitCodeCommandFailed()
|
||||
{
|
||||
$this->skipIfPHPSigchild();
|
||||
parent::testExitCodeCommandFailed();
|
||||
}
|
||||
|
||||
public function testProcessIsSignaledIfStopped()
|
||||
{
|
||||
$this->skipIfPHPSigchild();
|
||||
parent::testProcessIsSignaledIfStopped();
|
||||
}
|
||||
|
||||
public function testProcessWithTermSignal()
|
||||
{
|
||||
$this->skipIfPHPSigchild();
|
||||
parent::testProcessWithTermSignal();
|
||||
}
|
||||
|
||||
public function testProcessIsNotSignaled()
|
||||
{
|
||||
$this->skipIfPHPSigchild();
|
||||
parent::testProcessIsNotSignaled();
|
||||
}
|
||||
|
||||
public function testProcessWithoutTermSignal()
|
||||
{
|
||||
$this->skipIfPHPSigchild();
|
||||
parent::testProcessWithoutTermSignal();
|
||||
}
|
||||
|
||||
public function testExitCodeText()
|
||||
{
|
||||
$this->skipIfPHPSigchild();
|
||||
parent::testExitCodeText();
|
||||
}
|
||||
|
||||
public function testIsSuccessful()
|
||||
{
|
||||
$this->skipIfPHPSigchild();
|
||||
parent::testIsSuccessful();
|
||||
}
|
||||
|
||||
public function testIsNotSuccessful()
|
||||
{
|
||||
$this->skipIfPHPSigchild();
|
||||
parent::testIsNotSuccessful();
|
||||
}
|
||||
|
||||
public function testGetPid()
|
||||
{
|
||||
$this->skipIfPHPSigchild();
|
||||
parent::testGetPid();
|
||||
}
|
||||
|
||||
public function testGetPidIsNullBeforeStart()
|
||||
{
|
||||
$this->skipIfPHPSigchild();
|
||||
parent::testGetPidIsNullBeforeStart();
|
||||
}
|
||||
|
||||
public function testGetPidIsNullAfterRun()
|
||||
{
|
||||
$this->skipIfPHPSigchild();
|
||||
parent::testGetPidIsNullAfterRun();
|
||||
}
|
||||
|
||||
public function testSignal()
|
||||
{
|
||||
$this->skipIfPHPSigchild();
|
||||
parent::testSignal();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Process\Exception\LogicException
|
||||
*/
|
||||
public function testSignalProcessNotRunning()
|
||||
{
|
||||
$this->skipIfPHPSigchild();
|
||||
parent::testSignalProcessNotRunning();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testSignalWithWrongIntSignal()
|
||||
{
|
||||
$this->skipIfPHPSigchild();
|
||||
parent::testSignalWithWrongIntSignal();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testSignalWithWrongNonIntSignal()
|
||||
{
|
||||
$this->skipIfPHPSigchild();
|
||||
parent::testSignalWithWrongNonIntSignal();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getProcess($commandline, $cwd = null, array $env = null, $stdin = null, $timeout = 60, array $options = array())
|
||||
{
|
||||
return new Process($commandline, $cwd, $env, $stdin, $timeout, $options);
|
||||
}
|
||||
|
||||
private function skipIfPHPSigchild()
|
||||
{
|
||||
if ($this->enabledSigchild) {
|
||||
$this->markTestSkipped('Your PHP has been compiled with --enable-sigchild, this test can not be executed');
|
||||
}
|
||||
}
|
||||
}
|
31
vendor/symfony/process/Symfony/Component/Process/composer.json
vendored
Normal file
31
vendor/symfony/process/Symfony/Component/Process/composer.json
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "symfony/process",
|
||||
"type": "library",
|
||||
"description": "Symfony Process Component",
|
||||
"keywords": [],
|
||||
"homepage": "http://symfony.com",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "http://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": { "Symfony\\Component\\Process\\": "" }
|
||||
},
|
||||
"target-dir": "Symfony/Component/Process",
|
||||
"minimum-stability": "dev",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.3-dev"
|
||||
}
|
||||
}
|
||||
}
|
28
vendor/symfony/process/Symfony/Component/Process/phpunit.xml.dist
vendored
Normal file
28
vendor/symfony/process/Symfony/Component/Process/phpunit.xml.dist
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<phpunit backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
syntaxCheck="false"
|
||||
bootstrap="vendor/autoload.php"
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite name="Symfony Process Component Test Suite">
|
||||
<directory>./Tests/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory>./</directory>
|
||||
<exclude>
|
||||
<directory>./Tests</directory>
|
||||
</exclude>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
Reference in New Issue
Block a user