8000 [travis/appveyor] Wire simple-phpunit · symfony/symfony@b9fa27a · GitHub
[go: up one dir, main page]

Skip to content

Commit b9fa27a

Browse files
[travis/appveyor] Wire simple-phpunit
1 parent 58fa32b commit b9fa27a

File tree

5 files changed

+59
-25
lines changed

5 files changed

+59
-25
lines changed

.github/travis.php renamed to .github/build-packages.php

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,18 @@
88

99
$dirs = $_SERVER['argv'];
1010
array_shift($dirs);
11-
$branch = array_shift($dirs);
11+
$mergeBase = trim(shell_exec(sprintf('git merge-base %s HEAD', array_shift($dirs))));
1212
$version = array_shift($dirs);
1313

1414
$packages = array();
1515
$flags = PHP_VERSION_ID >= 50400 ? JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE : 0;
1616

17-
foreach ($dirs as $dir) {
18-
if (!system("git diff --name-only $branch...HEAD -- $dir", $exitStatus)) {
17+
foreach ($dirs as $k => $dir) {
18+
if (!system("git diff --name-only $mergeBase -- $dir", $exitStatus)) {
1919
if ($exitStatus) {
2020
exit($exitStatus);
2121
}
22+
unset($dirs[$k]);
2223
continue;
2324
}
2425
echo "$dir\n";
@@ -31,15 +32,17 @@
3132

3233
$package->repositories = array(array(
3334
'type' => 'composer',
34-
'url' => 'file://'.dirname(__DIR__).'/',
35+
'url' => 'file://'.str_replace(DIRECTORY_SEPARATOR, '/', dirname(__DIR__)).'/',
3536
));
36-
$json = rtrim(json_encode(array('repositories' => $package->repositories), $flags), "\n}").','.substr($json, 1);
37-
file_put_contents($dir.'/composer.json', $json);
37+
if (false === strpos($json, "\n \"repositories\": [\n")) {
38+
$json = rtrim(json_encode(array('repositories' => $package->repositories), $flags), "\n}").','.substr($json, 1);
39+
file_put_contents($dir.'/composer.json', $json);
40+
}
3841
passthru("cd $dir && tar -cf package.tar --exclude='package.tar' *");
3942

4043
$package->version = 'master' !== $version ? $version.'.999' : 'dev-master';
4144
$package->dist['type'] = 'tar';
42-
$package->dist['url'] = 'file://'.dirname(__DIR__)."/$dir/package.tar";
45+
$package->dist['url'] = 'file://'.str_replace(DIRECTORY_SEPARATOR, '/', dirname(__DIR__))."/$dir/package.tar";
4346

4447
$packages[$package->name][$package->version] = $package;
4548

@@ -52,3 +55,20 @@
5255
}
5356

5457
file_put_contents('packages.json', json_encode(compact('packages'), $flags));
58+
59+
if ($dirs) {
60+
$json = ltrim(file_get_contents('composer.json'));
61+
if (null === $package = json_decode($json)) {
62+
passthru("composer validate $dir/composer.json");
63+
exit(1);
64+
}
65+
66+
$package->repositories = array(array(
67+
'type' => 'composer',
68+
'url' => 'file://'.str_replace(DIRECTORY_SEPARATOR, '/', dirname(__DIR__)).'/',
69+
));
70+
if (false === strpos($json, "\n \"repositories\": [\n")) {
71+
$json = rtrim(json_encode(array('repositories' => $package->repositories), $flags), "\n}").','.substr($json, 1);
72+
file_put_contents('composer.json', $json);
73+
}
74+
}

.travis.yml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ matrix:
3434

3535
cache:
3636
directories:
37-
- .phpunit
37+
- vendor/symfony/phpunit-bridge/bin/.phpunit
3838
- php-$MIN_PHP
3939

4040
services:
@@ -64,31 +64,36 @@ before_install:
6464
- if [[ ! $skip && ! $PHP = hhvm* ]]; then echo extension = redis.so >> $INI_FILE; fi;
6565
- if [[ ! $skip && ! $PHP = hhvm* ]]; then phpenv config-rm xdebug.ini || echo "xdebug not available"; fi
6666
- if [[ ! $skip ]]; then [ -d ~/.composer ] || mkdir ~/.composer; cp .composer/* ~/.composer/; fi
67-
- if [[ ! $skip ]]; then ./phpunit install; fi
6867
- if [[ ! $skip ]]; then export PHPUNIT=$(readlink -f ./phpunit); fi
6968
- if [[ ! $skip ]]; then ldapadd -h localhost:3389 -D cn=admin,dc=symfony,dc=com -w symfony -f src/Symfony/Component/Ldap/Tests/Fixtures/data/base.ldif; fi
7069
- if [[ ! $skip ]]; then ldapadd -h localhost:3389 -D cn=admin,dc=symfony,dc=com -w symfony -f src/Symfony/Component/Ldap/Tests/Fixtures/data/fixtures.ldif; fi
7170

7271
install:
72+
- if [[ ! $skip && $deps ]]; then cp composer.json composer.json.orig; fi
73+
- if [[ ! $skip && $deps ]]; then echo -e '{\n"require":{'"$(grep phpunit-bridge composer.json)"'"php":"*"},"minimum-stability":"dev"}' > composer.json; fi
7374
- if [[ ! $skip ]]; then COMPONENTS=$(find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -printf '%h\n'); fi
7475
# Create local composer packages for each patched components and reference them in composer.json files when cross-testing components
75-
- if [[ ! $skip && $deps ]]; then git fetch origin $TRAVIS_BRANCH && php .github/travis.php FETCH_HEAD $TRAVIS_BRANCH $COMPONENTS; fi
76+
- if [[ ! $skip && $deps ]]; then php .github/build-packages.php HEAD^ $TRAVIS_BRANCH $COMPONENTS; fi
77+
- if [[ ! $skip && $deps ]]; then mv composer.json composer.json.phpunit; mv composer.json.orig composer.json; fi
78+
- if [[ ! $skip && ! $deps ]]; then php .github/build-packages.php HEAD^ $TRAVIS_BRANCH src/Symfony/Bridge/PhpUnit; fi
7679
# For the master branch when deps=high, the version before master is checked out and tested with the locally patched components
7780
- 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
78-
- 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
81+
- 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
7982
# Legacy tests are skipped when deps=high and when the current branch version has not the same major version number than the next one
8083
- 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
8184
- export COMPOSER_ROOT_VERSION=$SYMFONY_VERSION.x-dev
82-
- if [[ ! $deps ]]; then composer update; else export SYMFONY_DEPRECATIONS_HELPER=weak; fi
83-
- if [[ $TRAVIS_BRANCH = master ]]; then export SYMFONY_PHPUNIT_OVERLOAD=1; fi
84-
- if [[ ! $PHP = hhvm* ]]; then php -i; else hhvm --php -r 'print_r($_SERVER);print_r(ini_get_all());'; fi
85+
- if [[ ! $skip && $deps ]]; then export SYMFONY_DEPRECATIONS_HELPER=weak; fi
86+
- if [[ ! $skip && $deps ]]; then mv composer.json.phpunit composer.json; fi
87+
- if [[ ! $skip ]]; then composer update; fi
88+
- if [[ ! $skip ]]; then COMPOSER_ROOT_VERSION= ./phpunit install; fi
89+
- if [[ ! $skip && ! $PHP = hhvm* ]]; then php -i; else hhvm --php -r 'print_r($_SERVER);print_r(ini_get_all());'; fi
8590

8691
script:
8792
- if [[ $skip ]]; then echo -e "\\n\\e[1;34mIntermediate PHP version $PHP is skipped for pull requests.\\e[0m"; fi
8893
- if [[ ! $deps && ! $PHP = hhvm* ]]; then echo "$COMPONENTS" | parallel --gnu '$PHPUNIT --exclude-group tty,benchmark,intl-data {}'; fi
8994
- if [[ ! $deps && ! $PHP = hhvm* ]]; then echo -e "\\nRunning tests requiring tty"; $PHPUNIT --group tty; fi
9095
- if [[ ! $deps && $PHP = hhvm* ]]; then $PHPUNIT --exclude-group benchmark,intl-data; fi
91-
- if [[ ! $deps && $PHP = ${MIN_PHP%.*} ]]; then echo -e "1\\n0" | xargs -I{} sh -c 'echo "\\nPHP --enable-sigchild enhanced={}" && ENHANCE_SIGCHLD={} php-$MIN_PHP/sapi/cli/php .phpunit/phpunit-4.8/phpunit --colors=always src/Symfony/Component/Process/'; fi
96+
- if [[ ! $deps && $PHP = ${MIN_PHP%.*} ]]; then echo -e "1\\n0" | xargs -I{} sh -c 'echo "\\nPHP --enable-sigchild enhanced={}" && ENHANCE_SIGCHLD={} php-$MIN_PHP/sapi/cli/php vendor/symfony/phpunit-bridge/bin/.phpunit/phpunit-4.8/phpunit --colors=always src/Symfony/Component/Process/'; fi
9297
- if [[ $deps = high ]]; then echo "$COMPONENTS" | parallel --gnu -j10% 'cd {}; composer update --no-progress --ansi; $PHPUNIT --exclude-group tty,benchmark,intl-data'$LEGACY; fi
9398
- if [[ $deps = low ]]; then echo "$COMPONENTS" | parallel --gnu -j10% 'cd {}; composer update --no-progress --ansi --prefer-lowest --prefer-stable; $PHPUNIT --exclude-group tty,benchmark,intl-data'; fi
9499
# Test the PhpUnit bridge using the original phpunit script

appveyor.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ clone_folder: c:\projects\symfony
44

55
cache:
66
- c:\projects\symfony\composer.phar
7-
- .phpunit -> phpunit
7+
- vendor/symfony/phpunit-bridge/bin/.phpunit
88

99
init:
1010
- SET PATH=c:\php;%PATH%
@@ -46,18 +46,23 @@ install:
4646
- echo curl.cainfo=c:\php\cacert.pem >> php.ini-max
4747
- copy /Y php.ini-max php.ini
4848
- cd c:\projects\symfony
49-
- IF NOT EXIST composer.phar (appveyor DownloadFile https://getcomposer.org/download/1.2.0/composer.phar)
49+
- IF NOT EXIST composer.phar (appveyor DownloadFile https://getcomposer.org/download/1.2.1/composer.phar)
5050
- php composer.phar self-update
5151
- copy /Y .composer\* %APPDATA%\Composer\
52-
- php phpunit install
52+
- php .github/build-packages.php "HEAD^" %APPVEYOR_REPO_BRANCH% src\Symfony\Bridge\PhpUnit
5353
- IF %APPVEYOR_REPO_BRANCH%==master (SET COMPOSER_ROOT_VERSION=dev-master) ELSE (SET COMPOSER_ROOT_VERSION=%APPVEYOR_REPO_BRANCH%.x-dev)
5454
- php composer.phar update --no-progress --ansi
55+
- SET COMPOSER_ROOT_VERSION=
56+
- php phpunit install
5557

5658
test_script:
5759
- cd c:\projects\symfony
5860
- SET X=0
5961
- copy /Y c:\php\php.ini-min c:\php\php.ini
60-
- php phpunit symfony --exclude-group benchmark,intl-data || SET X=!errorlevel!
62+
- php phpunit src\Symfony --exclude-group benchmark,intl-data || SET X=!errorlevel!
6163
- copy /Y c:\php\php.ini-max c:\php\php.ini
62-
- php phpunit symfony --exclude-group benchmark,intl-data || SET X=!errorlevel!
64+
- php phpunit src\Symfony --exclude-group benchmark,intl-data || SET X=!errorlevel!
6365
- exit %X%
66+
67+
on_finish:
68+
- ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))

composer.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
"ocramius/proxy-manager": "~0.4|~1.0|~2.0",
8888
"predis/predis": "~1.0",
8989
"egulias/email-validator": "~1.2,>=1.2.8|~2.0",
90+
"symfony/phpunit-bridge": "~3.2",
9091
"symfony/polyfill-apcu": "~1.1",
9192
"symfony/security-acl": "~2.8|~3.0",
9293
"phpdocumentor/reflection-docblock": "^3.0"
@@ -115,11 +116,6 @@
115116
"**/Tests/"
116117
]
117118
},
118-
"autoload-dev": {
119-
"psr-4": {
120-
"Symfony\\Bridge\\PhpUnit\\": "src/Symfony/Bridge/PhpUnit/"
121-
}
122-
},
123119
"minimum-stability": "dev",
124120
"extra": {
125121
"branch-alias": {

phpunit

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
if (!file_exists(__DIR__.'/vendor/symfony/phpunit-bridge/bin/simple-phpunit')) {
5+
echo "Unable to find the `simple-phpunit` script in `vendor/symfony/phpunit-bridge/bin/`.\nPlease run `composer update` before running this command.\n";
6+
exit(1);
7+
}
8+
require __DIR__.'/vendor/symfony/phpunit-bridge/bin/simple-phpunit';

0 commit comments

Comments
 (0)
0