[travis/appveyor] Wire simple-phpunit
This commit is contained in:
parent
ddf8b27e14
commit
9eb8524d18
74
.github/build-packages.php
vendored
Normal file
74
.github/build-packages.php
vendored
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if (4 > $_SERVER['argc']) {
|
||||||
|
echo "Usage: branch version dir1 dir2 ... dirN\n";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
chdir(dirname(__DIR__));
|
||||||
|
|
||||||
|
$dirs = $_SERVER['argv'];
|
||||||
|
array_shift($dirs);
|
||||||
|
$mergeBase = trim(shell_exec(sprintf('git merge-base %s HEAD', array_shift($dirs))));
|
||||||
|
$version = array_shift($dirs);
|
||||||
|
|
||||||
|
$packages = array();
|
||||||
|
$flags = PHP_VERSION_ID >= 50400 ? JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE : 0;
|
||||||
|
|
||||||
|
foreach ($dirs as $k => $dir) {
|
||||||
|
if (!system("git diff --name-only $mergeBase -- $dir", $exitStatus)) {
|
||||||
|
if ($exitStatus) {
|
||||||
|
exit($exitStatus);
|
||||||
|
}
|
||||||
|
unset($dirs[$k]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
echo "$dir\n";
|
||||||
|
|
||||||
|
$json = ltrim(file_get_contents($dir.'/composer.json'));
|
||||||
|
if (null === $package = json_decode($json)) {
|
||||||
|
passthru("composer validate $dir/composer.json");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$package->repositories = array(array(
|
||||||
|
'type' => 'composer',
|
||||||
|
'url' => 'file://'.str_replace(DIRECTORY_SEPARATOR, '/', dirname(__DIR__)).'/',
|
||||||
|
));
|
||||||
|
if (false === strpos($json, "\n \"repositories\": [\n")) {
|
||||||
|
$json = rtrim(json_encode(array('repositories' => $package->repositories), $flags), "\n}").','.substr($json, 1);
|
||||||
|
file_put_contents($dir.'/composer.json', $json);
|
||||||
|
}
|
||||||
|
passthru("cd $dir && tar -cf package.tar --exclude='package.tar' *");
|
||||||
|
|
||||||
|
$package->version = $version.'.999';
|
||||||
|
$package->dist['type'] = 'tar';
|
||||||
|
$package->dist['url'] = 'file://'.str_replace(DIRECTORY_SEPARATOR, '/', dirname(__DIR__))."/$dir/package.tar";
|
||||||
|
|
||||||
|
$packages[$package->name][$package->version] = $package;
|
||||||
|
|
||||||
|
$versions = file_get_contents('https://packagist.org/packages/'.$package->name.'.json');
|
||||||
|
$versions = json_decode($versions);
|
||||||
|
|
||||||
|
foreach ($versions->package->versions as $v => $package) {
|
||||||
|
$packages[$package->name] += array($v => $package);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
file_put_contents('packages.json', json_encode(compact('packages'), $flags));
|
||||||
|
|
||||||
|
if ($dirs) {
|
||||||
|
$json = ltrim(file_get_contents('composer.json'));
|
||||||
|
if (null === $package = json_decode($json)) {
|
||||||
|
passthru("composer validate $dir/composer.json");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$package->repositories = array(array(
|
||||||
|
'type' => 'composer',
|
||||||
|
'url' => 'file://'.str_replace(DIRECTORY_SEPARATOR, '/', dirname(__DIR__)).'/',
|
||||||
|
));
|
||||||
|
if (false === strpos($json, "\n \"repositories\": [\n")) {
|
||||||
|
$json = rtrim(json_encode(array('repositories' => $package->repositories), $flags), "\n}").','.substr($json, 1);
|
||||||
|
file_put_contents('composer.json', $json);
|
||||||
|
}
|
||||||
|
}
|
54
.github/travis.php
vendored
54
.github/travis.php
vendored
@ -1,54 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
if (4 > $_SERVER['argc']) {
|
|
||||||
echo "Usage: branch version dir1 dir2 ... dirN\n";
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
chdir(dirname(__DIR__));
|
|
||||||
|
|
||||||
$dirs = $_SERVER['argv'];
|
|
||||||
array_shift($dirs);
|
|
||||||
$branch = array_shift($dirs);
|
|
||||||
$version = array_shift($dirs);
|
|
||||||
|
|
||||||
$packages = array();
|
|
||||||
$flags = PHP_VERSION_ID >= 50400 ? JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE : 0;
|
|
||||||
|
|
||||||
foreach ($dirs as $dir) {
|
|
||||||
if (!system("git diff --name-only $branch...HEAD -- $dir", $exitStatus)) {
|
|
||||||
if ($exitStatus) {
|
|
||||||
exit($exitStatus);
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
echo "$dir\n";
|
|
||||||
|
|
||||||
$json = ltrim(file_get_contents($dir.'/composer.json'));
|
|
||||||
if (null === $package = json_decode($json)) {
|
|
||||||
passthru("composer validate $dir/composer.json");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
$package->repositories = array(array(
|
|
||||||
'type' => 'composer',
|
|
||||||
'url' => 'file://'.dirname(__DIR__).'/',
|
|
||||||
));
|
|
||||||
$json = rtrim(json_encode(array('repositories' => $package->repositories), $flags), "\n}").','.substr($json, 1);
|
|
||||||
file_put_contents($dir.'/composer.json', $json);
|
|
||||||
passthru("cd $dir && tar -cf package.tar --exclude='package.tar' *");
|
|
||||||
|
|
||||||
$package->version = $version.'.999';
|
|
||||||
$package->dist['type'] = 'tar';
|
|
||||||
$package->dist['url'] = 'file://'.dirname(__DIR__)."/$dir/package.tar";
|
|
||||||
|
|
||||||
$packages[$package->name][$package->version] = $package;
|
|
||||||
|
|
||||||
$versions = file_get_contents('https://packagist.org/packages/'.$package->name.'.json');
|
|
||||||
$versions = json_decode($versions);
|
|
||||||
|
|
||||||
foreach ($versions->package->versions as $v => $package) {
|
|
||||||
$packages[$package->name] += array($v => $package);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
file_put_contents('packages.json', json_encode(compact('packages'), $flags));
|
|
17
.travis.yml
17
.travis.yml
@ -58,22 +58,27 @@ before_install:
|
|||||||
- if [[ ! $skip && ! $PHP = hhvm* ]]; then echo extension = ldap.so >> $INI_FILE; fi
|
- if [[ ! $skip && ! $PHP = hhvm* ]]; then echo extension = ldap.so >> $INI_FILE; fi
|
||||||
- if [[ ! $skip && ! $PHP = hhvm* ]]; then phpenv config-rm xdebug.ini || echo "xdebug not available"; fi
|
- if [[ ! $skip && ! $PHP = hhvm* ]]; then phpenv config-rm xdebug.ini || echo "xdebug not available"; fi
|
||||||
- if [[ ! $skip ]]; then [ -d ~/.composer ] || mkdir ~/.composer; cp .composer/* ~/.composer/; fi
|
- if [[ ! $skip ]]; then [ -d ~/.composer ] || mkdir ~/.composer; cp .composer/* ~/.composer/; fi
|
||||||
- if [[ ! $skip ]]; then ./phpunit install; fi
|
|
||||||
- if [[ ! $skip ]]; then export PHPUNIT=$(readlink -f ./phpunit); fi
|
- if [[ ! $skip ]]; then export PHPUNIT=$(readlink -f ./phpunit); fi
|
||||||
|
|
||||||
install:
|
install:
|
||||||
|
- if [[ ! $skip && $deps ]]; then cp composer.json composer.json.orig; fi
|
||||||
|
- if [[ ! $skip && $deps ]]; then echo -e '{\n"require":{'"$(grep phpunit-bridge composer.json)"'"php":"*"},"minimum-stability":"dev"}' > composer.json; fi
|
||||||
- if [[ ! $skip ]]; then COMPONENTS=$(find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -printf '%h\n'); fi
|
- if [[ ! $skip ]]; then COMPONENTS=$(find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -printf '%h\n'); fi
|
||||||
# Create local composer packages for each patched components and reference them in composer.json files when cross-testing components
|
# Create local composer packages for each patched components and reference them in composer.json files when cross-testing components
|
||||||
- if [[ ! $skip && $deps ]]; then git fetch origin $TRAVIS_BRANCH && php .github/travis.php FETCH_HEAD $TRAVIS_BRANCH $COMPONENTS; fi
|
- if [[ ! $skip && $deps ]]; then php .github/build-packages.php HEAD^ $TRAVIS_BRANCH $COMPONENTS; fi
|
||||||
|
- if [[ ! $skip && $deps ]]; then mv composer.json composer.json.phpunit; mv composer.json.orig composer.json; fi
|
||||||
|
- if [[ ! $skip && ! $deps ]]; then php .github/build-packages.php HEAD^ $TRAVIS_BRANCH src/Symfony/Bridge/PhpUnit; fi
|
||||||
# For the master branch when deps=high, the version before master is checked out and tested with the locally patched components
|
# For the master branch when deps=high, the version before master is checked out and tested with the locally patched components
|
||||||
- if [[ $deps = high && $TRAVIS_BRANCH = master ]]; then SYMFONY_VERSION=$(git ls-remote --heads | grep -o '/[1-9].*' | tail -n 1 | sed s/.//); else SYMFONY_VERSION=$(cat composer.json | grep '^ *"dev-master". *"[1-9]' | grep -o '[0-9.]*'); fi
|
- if [[ $deps = high && $TRAVIS_BRANCH = master ]]; then SYMFONY_VERSION=$(git ls-remote --heads | grep -o '/[1-9].*' | tail -n 1 | sed s/.//); else SYMFONY_VERSION=$(cat composer.json | grep '^ *"dev-master". *"[1-9]' | grep -o '[0-9.]*'); fi
|
||||||
- if [[ $deps = high && $TRAVIS_BRANCH = master ]]; then git fetch origin $SYMFONY_VERSION; git checkout -m FETCH_HEAD; COMPONENTS=$(find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -printf '%h\n'); ./phpunit install; fi
|
- if [[ $deps = high && $TRAVIS_BRANCH = master ]]; then git fetch origin $SYMFONY_VERSION; git checkout -m FETCH_HEAD; COMPONENTS=$(find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -printf '%h\n'); fi
|
||||||
# Legacy tests are skipped when deps=high and when the current branch version has not the same major version number than the next one
|
# Legacy tests are skipped when deps=high and when the current branch version has not the same major version number than the next one
|
||||||
- if [[ $deps = high && ${SYMFONY_VERSION%.*} != $(git show $(git ls-remote --heads | grep -FA1 /$SYMFONY_VERSION | tail -n 1):composer.json | grep '^ *"dev-master". *"[1-9]' | grep -o '[0-9]*' | head -n 1) ]]; then LEGACY=,legacy; fi
|
- if [[ $deps = high && ${SYMFONY_VERSION%.*} != $(git show $(git ls-remote --heads | grep -FA1 /$SYMFONY_VERSION | tail -n 1):composer.json | grep '^ *"dev-master". *"[1-9]' | grep -o '[0-9]*' | head -n 1) ]]; then LEGACY=,legacy; fi
|
||||||
- export COMPOSER_ROOT_VERSION=$SYMFONY_VERSION.x-dev
|
- export COMPOSER_ROOT_VERSION=$SYMFONY_VERSION.x-dev
|
||||||
- if [[ ! $deps ]]; then composer update; else export SYMFONY_DEPRECATIONS_HELPER=weak; fi
|
- if [[ ! $skip && $deps ]]; then export SYMFONY_DEPRECATIONS_HELPER=weak; fi
|
||||||
- if [[ $TRAVIS_BRANCH = master ]]; then export SYMFONY_PHPUNIT_OVERLOAD=1; fi
|
- if [[ ! $skip && $deps ]]; then mv composer.json.phpunit composer.json; fi
|
||||||
- if [[ ! $PHP = hhvm* ]]; then php -i; else hhvm --php -r 'print_r($_SERVER);print_r(ini_get_all());'; fi
|
- if [[ ! $skip ]]; then composer update; fi
|
||||||
|
- if [[ ! $skip ]]; then COMPOSER_ROOT_VERSION= ./phpunit install; fi
|
||||||
|
- if [[ ! $skip && ! $PHP = hhvm* ]]; then php -i; else hhvm --php -r 'print_r($_SERVER);print_r(ini_get_all());'; fi
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- if [[ $skip ]]; then echo -e "\\n\\e[1;34mIntermediate PHP version $PHP is skipped for pull requests.\\e[0m"; fi
|
- if [[ $skip ]]; then echo -e "\\n\\e[1;34mIntermediate PHP version $PHP is skipped for pull requests.\\e[0m"; fi
|
||||||
|
10
appveyor.yml
10
appveyor.yml
@ -48,18 +48,20 @@ install:
|
|||||||
- echo curl.cainfo=c:\php\cacert.pem >> php.ini-max
|
- echo curl.cainfo=c:\php\cacert.pem >> php.ini-max
|
||||||
- copy /Y php.ini-max php.ini
|
- copy /Y php.ini-max php.ini
|
||||||
- cd c:\projects\symfony
|
- cd c:\projects\symfony
|
||||||
- IF NOT EXIST composer.phar (appveyor DownloadFile https://getcomposer.org/download/1.2.0/composer.phar)
|
- IF NOT EXIST composer.phar (appveyor DownloadFile https://getcomposer.org/download/1.2.1/composer.phar)
|
||||||
- php composer.phar self-update
|
- php composer.phar self-update
|
||||||
- copy /Y .composer\* %APPDATA%\Composer\
|
- copy /Y .composer\* %APPDATA%\Composer\
|
||||||
- php phpunit install
|
- php .github/build-packages.php "HEAD^" %APPVEYOR_REPO_BRANCH% src\Symfony\Bridge\PhpUnit
|
||||||
- IF %APPVEYOR_REPO_BRANCH%==master (SET COMPOSER_ROOT_VERSION=dev-master) ELSE (SET COMPOSER_ROOT_VERSION=%APPVEYOR_REPO_BRANCH%.x-dev)
|
- IF %APPVEYOR_REPO_BRANCH%==master (SET COMPOSER_ROOT_VERSION=dev-master) ELSE (SET COMPOSER_ROOT_VERSION=%APPVEYOR_REPO_BRANCH%.x-dev)
|
||||||
- php composer.phar update --no-progress --ansi
|
- php composer.phar update --no-progress --ansi
|
||||||
|
- SET COMPOSER_ROOT_VERSION=
|
||||||
|
- php phpunit install
|
||||||
|
|
||||||
test_script:
|
test_script:
|
||||||
- cd c:\projects\symfony
|
- cd c:\projects\symfony
|
||||||
- SET X=0
|
- SET X=0
|
||||||
- copy /Y c:\php\php.ini-min c:\php\php.ini
|
- copy /Y c:\php\php.ini-min c:\php\php.ini
|
||||||
- php phpunit symfony --exclude-group benchmark,intl-data || SET X=!errorlevel!
|
- php phpunit src\Symfony --exclude-group benchmark,intl-data || SET X=!errorlevel!
|
||||||
- copy /Y c:\php\php.ini-max c:\php\php.ini
|
- copy /Y c:\php\php.ini-max c:\php\php.ini
|
||||||
- php phpunit symfony --exclude-group benchmark,intl-data || SET X=!errorlevel!
|
- php phpunit src\Symfony --exclude-group benchmark,intl-data || SET X=!errorlevel!
|
||||||
- exit %X%
|
- exit %X%
|
||||||
|
@ -78,6 +78,7 @@
|
|||||||
"monolog/monolog": "~1.11",
|
"monolog/monolog": "~1.11",
|
||||||
"ircmaxell/password-compat": "~1.0",
|
"ircmaxell/password-compat": "~1.0",
|
||||||
"ocramius/proxy-manager": "~0.4|~1.0|~2.0",
|
"ocramius/proxy-manager": "~0.4|~1.0|~2.0",
|
||||||
|
"symfony/phpunit-bridge": "~3.2",
|
||||||
"egulias/email-validator": "~1.2,>=1.2.1"
|
"egulias/email-validator": "~1.2,>=1.2.1"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
@ -99,11 +100,6 @@
|
|||||||
"**/Tests/"
|
"**/Tests/"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"autoload-dev": {
|
|
||||||
"psr-4": {
|
|
||||||
"Symfony\\Bridge\\PhpUnit\\": "src/Symfony/Bridge/PhpUnit/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"minimum-stability": "dev",
|
"minimum-stability": "dev",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
|
213
phpunit
213
phpunit
@ -1,212 +1,9 @@
|
|||||||
#!/usr/bin/env php
|
#!/usr/bin/env php
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
if (!file_exists(__DIR__.'/vendor/symfony/phpunit-bridge/bin/simple-phpunit')) {
|
||||||
* This file is part of the Symfony package.
|
echo "Unable to find the `simple-phpunit` script in `vendor/symfony/phpunit-bridge/bin/`.\nPlease run `composer update` before running this command.\n";
|
||||||
*
|
exit(1);
|
||||||
* (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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Please update when phpunit needs to be reinstalled with fresh deps:
|
|
||||||
// Cache-Id-Version: 2016-06-29 13:45 UTC
|
|
||||||
|
|
||||||
use Symfony\Component\Process\ProcessUtils;
|
|
||||||
|
|
||||||
error_reporting(-1);
|
|
||||||
require __DIR__.'/src/Symfony/Component/Process/ProcessUtils.php';
|
|
||||||
|
|
||||||
// PHPUnit 4.8 does not support PHP 7, while 5.1 requires PHP 5.6+
|
|
||||||
$PHPUNIT_VERSION = PHP_VERSION_ID >= 50600 ? '5.1' : '4.8';
|
|
||||||
$PHPUNIT_DIR = __DIR__.'/.phpunit';
|
|
||||||
$PHP = defined('PHP_BINARY') ? PHP_BINARY : 'php';
|
|
||||||
$PHP = ProcessUtils::escapeArgument($PHP);
|
|
||||||
if ('phpdbg' === PHP_SAPI) {
|
|
||||||
$PHP .= ' -qrr';
|
|
||||||
}
|
}
|
||||||
|
putenv('SYMFONY_PHPUNIT_DIR='.__DIR__.'/.phpunit');
|
||||||
$COMPOSER = file_exists($COMPOSER = __DIR__.'/composer.phar') || ($COMPOSER = rtrim('\\' === DIRECTORY_SEPARATOR ? preg_replace('/[\r\n].*/', '', `where.exe composer.phar`) : `which composer.phar`))
|
require __DIR__.'/vendor/symfony/phpunit-bridge/bin/simple-phpunit';
|
||||||
? $PHP.' '.ProcessUtils::escapeArgument($COMPOSER)
|
|
||||||
: 'composer';
|
|
||||||
|
|
||||||
if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit") || md5_file(__FILE__) !== @file_get_contents("$PHPUNIT_DIR/.$PHPUNIT_VERSION.md5")) {
|
|
||||||
// Build a standalone phpunit without symfony/yaml
|
|
||||||
|
|
||||||
$oldPwd = getcwd();
|
|
||||||
@mkdir($PHPUNIT_DIR);
|
|
||||||
chdir($PHPUNIT_DIR);
|
|
||||||
if (file_exists("phpunit-$PHPUNIT_VERSION")) {
|
|
||||||
passthru(sprintf('\\' === DIRECTORY_SEPARATOR ? '(del /S /F /Q %s & rmdir %1$s) >nul': 'rm -rf %s', "phpunit-$PHPUNIT_VERSION"));
|
|
||||||
}
|
|
||||||
if (extension_loaded('openssl') && ini_get('allow_url_fopen')) {
|
|
||||||
stream_copy_to_stream(fopen("https://github.com/sebastianbergmann/phpunit/archive/$PHPUNIT_VERSION.zip", 'rb'), fopen("$PHPUNIT_VERSION.zip", 'wb'));
|
|
||||||
} else {
|
|
||||||
@unlink("$PHPUNIT_VERSION.zip");
|
|
||||||
passthru("wget https://github.com/sebastianbergmann/phpunit/archive/$PHPUNIT_VERSION.zip");
|
|
||||||
}
|
|
||||||
$zip = new ZipArchive();
|
|
||||||
$zip->open("$PHPUNIT_VERSION.zip");
|
|
||||||
$zip->extractTo(getcwd());
|
|
||||||
$zip->close();
|
|
||||||
chdir("phpunit-$PHPUNIT_VERSION");
|
|
||||||
passthru("$COMPOSER remove --no-update phpspec/prophecy");
|
|
||||||
passthru("$COMPOSER remove --no-update symfony/yaml");
|
|
||||||
if (5.1 <= $PHPUNIT_VERSION && $PHPUNIT_VERSION < 5.4) {
|
|
||||||
passthru("$COMPOSER require --no-update phpunit/phpunit-mock-objects \"~3.1.0\"");
|
|
||||||
}
|
|
||||||
passthru("$COMPOSER require --dev --no-update symfony/phpunit-bridge \">=3.2@dev\"");
|
|
||||||
passthru("$COMPOSER install --prefer-dist --no-progress --ansi", $exit);
|
|
||||||
if ($exit) {
|
|
||||||
exit($exit);
|
|
||||||
}
|
|
||||||
file_put_contents('phpunit', <<<'EOPHP'
|
|
||||||
<?php
|
|
||||||
|
|
||||||
define('PHPUNIT_COMPOSER_INSTALL', __DIR__.'/vendor/autoload.php');
|
|
||||||
|
|
||||||
$loader = require PHPUNIT_COMPOSER_INSTALL;
|
|
||||||
|
|
||||||
if (getenv('SYMFONY_PHPUNIT_OVERLOAD') && file_exists(__DIR__.'/../../src/Symfony/Bridge/PhpUnit')) {
|
|
||||||
$loader->addPsr4('Symfony\\Bridge\\PhpUnit\\', array('src/Symfony/Bridge/PhpUnit'), true);
|
|
||||||
}
|
|
||||||
unset($loader);
|
|
||||||
Symfony\Bridge\PhpUnit\TextUI\Command::main();
|
|
||||||
|
|
||||||
EOPHP
|
|
||||||
);
|
|
||||||
chdir('..');
|
|
||||||
file_put_contents(".$PHPUNIT_VERSION.md5", md5_file(__FILE__));
|
|
||||||
chdir($oldPwd);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
$cmd = array_map('Symfony\Component\Process\ProcessUtils::escapeArgument', $argv);
|
|
||||||
$exit = 0;
|
|
||||||
|
|
||||||
if (isset($argv[1]) && 'symfony' === $argv[1]) {
|
|
||||||
array_shift($cmd);
|
|
||||||
}
|
|
||||||
|
|
||||||
$cmd[0] = sprintf('%s %s --colors=always', $PHP, ProcessUtils::escapeArgument("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit"));
|
|
||||||
$cmd = str_replace('%', '%%', implode(' ', $cmd)).' %1$s';
|
|
||||||
|
|
||||||
if ('\\' === DIRECTORY_SEPARATOR) {
|
|
||||||
$cmd = 'cmd /v:on /d /c "('.$cmd.')%2$s"';
|
|
||||||
} else {
|
|
||||||
$cmd .= '%2$s';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($argv[1]) && 'symfony' === $argv[1]) {
|
|
||||||
// Find Symfony components in plain php for Windows portability
|
|
||||||
|
|
||||||
$oldPwd = getcwd();
|
|
||||||
chdir(__DIR__);
|
|
||||||
$finder = new RecursiveDirectoryIterator('src/Symfony', FilesystemIterator::KEY_AS_FILENAME | FilesystemIterator::UNIX_PATHS);
|
|
||||||
$finder = new RecursiveIteratorIterator($finder);
|
|
||||||
$finder->setMaxDepth(3);
|
|
||||||
|
|
||||||
$skippedTests = isset($_SERVER['SYMFONY_PHPUNIT_SKIPPED_TESTS']) ? $_SERVER['SYMFONY_PHPUNIT_SKIPPED_TESTS'] : false;
|
|
||||||
$runningProcs = array();
|
|
||||||
|
|
||||||
foreach ($finder as $file => $fileInfo) {
|
|
||||||
if ('phpunit.xml.dist' === $file) {
|
|
||||||
$component = dirname($fileInfo->getPathname());
|
|
||||||
|
|
||||||
// Run phpunit tests in parallel
|
|
||||||
|
|
||||||
if ($skippedTests) {
|
|
||||||
putenv("SYMFONY_PHPUNIT_SKIPPED_TESTS=$component/$skippedTests");
|
|
||||||
}
|
|
||||||
|
|
||||||
$c = ProcessUtils::escapeArgument($component);
|
|
||||||
|
|
||||||
if ($proc = proc_open(sprintf($cmd, $c, " > $c/phpunit.stdout 2> $c/phpunit.stderr"), array(), $pipes)) {
|
|
||||||
$runningProcs[$component] = $proc;
|
|
||||||
} else {
|
|
||||||
$exit = 1;
|
|
||||||
echo "\033[41mKO\033[0m $component\n\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
chdir($oldPwd);
|
|
||||||
|
|
||||||
// Fixes for colors support on appveyor
|
|
||||||
// See https://github.com/appveyor/ci/issues/373
|
|
||||||
$colorFixes = array(
|
|
||||||
array("S\033[0m\033[0m\033[36m\033[1mS", "E\033[0m\033[0m\033[31m\033[1mE", "I\033[0m\033[0m\033[33m\033[1mI", "F\033[0m\033[0m\033[41m\033[37mF"),
|
|
||||||
array("SS", "EE", "II", "FF"),
|
|
||||||
);
|
|
||||||
$colorFixes[0] = array_merge($colorFixes[0], $colorFixes[0]);
|
|
||||||
$colorFixes[1] = array_merge($colorFixes[1], $colorFixes[1]);
|
|
||||||
|
|
||||||
while ($runningProcs) {
|
|
||||||
usleep(300000);
|
|
||||||
$terminatedProcs = array();
|
|
||||||
foreach ($runningProcs as $component => $proc) {
|
|
||||||
$procStatus = proc_get_status($proc);
|
|
||||||
if (!$procStatus['running']) {
|
|
||||||
$terminatedProcs[$component] = $procStatus['exitcode'];
|
|
||||||
unset($runningProcs[$component]);
|
|
||||||
proc_close($proc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($terminatedProcs as $component => $procStatus) {
|
|
||||||
foreach (array('out', 'err') as $file) {
|
|
||||||
$file = "$component/phpunit.std$file";
|
|
||||||
|
|
||||||
if ('\\' === DIRECTORY_SEPARATOR) {
|
|
||||||
$h = fopen($file, 'rb');
|
|
||||||
while (false !== $line = fgets($h)) {
|
|
||||||
echo str_replace($colorFixes[0], $colorFixes[1], preg_replace(
|
|
||||||
'/(\033\[[0-9]++);([0-9]++m)(?:(.)(\033\[0m))?/',
|
|
||||||
"$1m\033[$2$3$4$4",
|
|
||||||
$line
|
|
||||||
));
|
|
||||||
}
|
|
||||||
fclose($h);
|
|
||||||
} else {
|
|
||||||
readfile($file);
|
|
||||||
}
|
|
||||||
unlink($file);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fail on any individual component failures but ignore some error codes on Windows when APCu is enabled:
|
|
||||||
// STATUS_STACK_BUFFER_OVERRUN (-1073740791/0xC0000409)
|
|
||||||
// STATUS_ACCESS_VIOLATION (-1073741819/0xC0000005)
|
|
||||||
// STATUS_HEAP_CORRUPTION (-1073740940/0xC0000374)
|
|
||||||
if ($procStatus && ('\\' !== DIRECTORY_SEPARATOR || !extension_loaded('apcu') || !ini_get('apc.enable_cli') || !in_array($procStatus, array(-1073740791, -1073741819, -1073740940)))) {
|
|
||||||
$exit = $procStatus;
|
|
||||||
echo "\033[41mKO\033[0m $component\n\n";
|
|
||||||
} else {
|
|
||||||
echo "\033[32mOK\033[0m $component\n\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} elseif (!isset($argv[1]) || 'install' !== $argv[1]) {
|
|
||||||
// Run regular phpunit in a subprocess
|
|
||||||
|
|
||||||
$errFile = tempnam(sys_get_temp_dir(), 'phpunit.stderr.');
|
|
||||||
if ($proc = proc_open(sprintf($cmd, '', ' 2> '.ProcessUtils::escapeArgument($errFile)), array(1 => array('pipe', 'w')), $pipes)) {
|
|
||||||
stream_copy_to_stream($pipes[1], STDOUT);
|
|
||||||
fclose($pipes[1]);
|
|
||||||
$exit = proc_close($proc);
|
|
||||||
|
|
||||||
readfile($errFile);
|
|
||||||
unlink($errFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!file_exists($component = array_pop($argv))) {
|
|
||||||
$component = basename(getcwd());
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($exit) {
|
|
||||||
echo "\033[41mKO\033[0m $component\n\n";
|
|
||||||
} else {
|
|
||||||
echo "\033[32mOK\033[0m $component\n\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
exit($exit);
|
|
||||||
|
Reference in New Issue
Block a user