8000 minor #15993 [ci] Display fastest results first when running tests in… · symfony/symfony@d8dc8f2 · GitHub
[go: up one dir, main page]

Skip to content

Commit d8dc8f2

Browse files
committed
minor #15993 [ci] Display fastest results first when running tests in parallel (nicolas-grekas)
This PR was merged into the 2.3 branch. Discussion ---------- [ci] Display fastest results first when running tests in parallel | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Keeping order prevents seeing failures early as they happen. I propose to display tests results asap instead. Best viewed with: https://github.com/symfony/symfony/pull/15993/files?w=1 Commits ------- 3d6c864 [ci] Display fastest results first when running tests in parallel
2 parents e1ede46 + 3d6c864 commit d8dc8f2

File tree

3 files changed

+45
-35
lines changed

3 files changed

+45
-35
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ install:
4444
- if [ "$deps" != "no" ]; then php .travis.php $TRAVIS_COMMIT_RANGE $TRAVIS_BRANCH $COMPONENTS; fi;
4545

4646
script:
47-
- if [ "$deps" = "no" ]; then echo "$COMPONENTS" | parallel --gnu --keep-order 'echo -e "\\nRunning {} tests"; $PHPUNIT --exclude-group tty,benchmark,intl-data {}'; fi;
47+
- if [ "$deps" = "no" ]; then echo "$COMPONENTS" | parallel --gnu 'echo -e "\\nRunning {} tests"; $PHPUNIT --exclude-group tty,benchmark,intl-data {}'; fi;
4848
- if [ "$deps" = "no" ]; then echo -e "\\nRunning tests requiring tty"; $PHPUNIT --group tty; fi;
49-
- if [ "$deps" = "high" ]; then echo "$COMPONENTS" | parallel --gnu --keep-order -j10% 'echo -e "\\nRunning {} tests"; cd {}; composer --prefer-source update; $PHPUNIT --exclude-group tty,benchmark,intl-data'; fi;
50-
- if [ "$deps" = "low" ]; then echo "$COMPONENTS" | parallel --gnu --keep-order -j10% 'echo -e "\\nRunning {} tests"; cd {}; composer --prefer-source --prefer-lowest --prefer-stable update; $PHPUNIT --exclude-group tty,benchmark,intl-data'; fi;
49+
- if [ "$deps" = "high" ]; then echo "$COMPONENTS" | parallel --gnu -j10% 'echo -e "\\nRunning {} tests"; cd {}; composer --prefer-source update; $PHPUNIT --exclude-group tty,benchmark,intl-data'; fi;
50+
- if [ "$deps" = "low" ]; then echo "$COMPONENTS" | parallel --gnu -j10% 'echo -e "\\nRunning {} tests"; cd {}; composer --prefer-source --prefer-lowest --prefer-stable update; $PHPUNIT --exclude-group tty,benchmark,intl-data'; fi;

phpunit

Lines changed: 38 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ $exit = 0;
3333
if (isset($argv[1]) && 'symfony' === $argv[1]) {
3434
// Find Symfony components in plain php for Windows portability
3535

36-
$finder = new RecursiveDirectoryIterator('src/Symfony', FilesystemIterator::KEY_AS_FILENAME | FilesystemIterator::UNIX_PATHS);
36+
$finder = new RecursiveDirectoryIterator(__DIR__.'/src/Symfony', FilesystemIterator::KEY_AS_FILENAME | FilesystemIterator::UNIX_PATHS);
3737
$finder = new RecursiveIteratorIterator($finder);
3838
$finder->setMaxDepth(3);
3939

4040
array_shift($cmd);
4141
$cmd[0] = "php $PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit --colors=always";
42-
$procs = array();
42+
$runningProcs = array();
4343

4444
foreach ($finder as $file => $fileInfo) {
4545
if ('phpunit.xml.dist' === $file) {
@@ -50,7 +50,7 @@ if (isset($argv[1]) && 'symfony' === $argv[1]) {
5050
$c = escapeshellarg($component);
5151

5252
if ($proc = proc_open(implode(' ', $cmd)." $c > $c/phpunit.stdout 2> $c/phpunit.stderr", array(), $pipes)) {
53-
$procs[$component] = $proc;
53+
$runningProcs[$component] = $proc;
5454
} else {
5555
$exit = 1;
5656
echo "\033[41mKO\033[0m $component\n\n";
@@ -59,44 +59,54 @@ if (isset($argv[1]) && 'symfony' === $argv[1]) {
5959
}
6060

6161
// Fixes for colors support on appveyor
62-
// See http://help.appveyor.com/discussions/suggestions/197-support-ansi-color-codes
62+
// See https://github.com/appveyor/ci/issues/373
6363
$colorFixes = array(
6464
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\ 10000 033[41m\033[37mF"),
6565
array("SS", "EE", "II", "FF"),
6666
);
6767
$colorFixes[0] = array_merge($colorFixes[0], $colorFixes[0]);
6868
$colorFixes[1] = array_merge($colorFixes[1], $colorFixes[1]);
6969

70-
foreach ($procs as $component => $proc) {
71-
$procStatus = proc_close($proc);
72-
73-
foreach (array('out', 'err') as $file) {
74-
$file = "$component/phpunit.std$file";
70+
while ($runningProcs) {
71+
usleep(300000);
72+
$terminatedProcs = array();
73+
foreach ($runningProcs as $component => $proc) {
74+
$procStatus = proc_get_status($proc);
75+
if (!$procStatus['running']) {
76+
$terminatedProcs[$component] = $procStatus['exitcode'];
77+
unset($runningProcs[$component]);
78+
proc_close($proc);
79+
}
80+
}
7581

76-
if ('\\' === DIRECTORY_SEPARATOR) {
77-
$h = fopen($file, 'rb');
78-
while (false !== $line = fgets($h)) {
79-
echo str_replace($colorFixes[0], $colorFixes[1], preg_replace(
80-
'/(\033\[[0-9]++);([0-9]++m)(?:(.)(\033\[0m))?/',
81-
"$1m\033[$2$3$4$4",
82-
$line
83-
));
82+
foreach ($terminatedProcs as $component => $procStatus) {
83+
foreach (array('out', 'err') as $file) {
84+
$file = "$component/phpunit.std$file";
85+
86+
if ('\\' === DIRECTORY_SEPARATOR) {
87+
$h = fopen($file, 'rb');
88+
while (false !== $line = fgets($h)) {
89+
echo str_replace($colorFixes[0], $colorFixes[1], preg_replace(
90+
'/(\033\[[0-9]++);([0-9]++m)(?:(.)(\033\[0m))?/',
91+
"$1m\033[$2$3$4$4",
92+
$line
93+
));
94+
}
95+
fclose($h);
96+
} else {
97+
readfile($file);
8498
}
85-
fclose($h);
86-
} else {
87-
readfile($file);
99+
unlink($file);
88100
}
89-
unlink($file);
90-
}
91101

92-
if ($procStatus) {
93-
$exit = 1;
94-
echo "\033[41mKO\033[0m $component\n\n";
95-
} else {
96-
echo "\033[32mOK\033[0m $component\n\n";
102+
if ($procStatus) {
103+
$exit = 1;
104+
echo "\033[41mKO\033[0m $component\n\n";
105+
} else {
106+
echo "\033[32mOK\033[0m $component\n\n";
107+
}
97108
}
98109
}
99-
100110
} elseif (!isset($argv[1]) || 'install' !== $argv[1]) {
101111
// Run regular phpunit in a subprocess
102112

src/Symfony/Component/Finder/Tests/Iterator/RecursiveDirectoryIteratorTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class RecursiveDirectoryIteratorTest extends IteratorTestCase
2121
public function testRewindOnFtp()
2222
{
2323
try {
24-
$i = new RecursiveDirectoryIterator('ftp://ftp.mozilla.org/', \RecursiveDirectoryIterator::SKIP_DOTS);
24+
$i = new RecursiveDirectoryIterator('ftp://speedtest.tele2.net/', \RecursiveDirectoryIterator::SKIP_DOTS);
2525
} catch (\UnexpectedValueException $e) {
2626
$this->markTestSkipped('Unsupported stream "ftp".');
2727
}
@@ -37,14 +37,14 @@ public function testRewindOnFtp()
3737
public function testSeekOnFtp()
3838
{
3939
try {
40-
$i = new RecursiveDirectoryIterator('ftp://ftp.mozilla.org/', \RecursiveDirectoryIterator::SKIP_DOTS);
40+
$i = new RecursiveDirectoryIterator('ftp://speedtest.tele2.net/', \RecursiveDirectoryIterator::SKIP_DOTS);
4141
} catch (\UnexpectedValueException $e) {
4242
$this->markTestSkipped('Unsupported stream "ftp".');
4343
}
4444

4545
$contains = array(
46-
'ftp://ftp.mozilla.org'.DIRECTORY_SEPARATOR.'README',
47-
'ftp://ftp.mozilla.org'.DIRECTORY_SEPARATOR.'pub',
46+
'ftp://speedtest.tele2.net'.DIRECTORY_SEPARATOR.'1000GB.zip',
47+
'ftp://speedtest.tele2.net'.DIRECTORY_SEPARATOR.'100GB.zip',
4848
);
4949
$actual = array();
5050

0 commit comments

Comments
 (0)
0