Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 929b313

Browse files
bug #19927 [Bridge/PhpUnit] Fix running subparts of components (nicolas-grekas)
This PR was merged into the 3.2-dev branch. Discussion ---------- [Bridge/PhpUnit] Fix running subparts of components | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | Tests pass? | yes | License | MIT As spotted by @jakzal in #19921 (comment) Diff best viewed ignoring white spaces: https://github.com/symfony/symfony/pull/19927/files?w=1 Commits ------- 37e6c1c [Bridge/PhpUnit] Fix running subparts of components
2 parents 1d4bee5 + 37e6c1c commit 929b313

File tree

1 file changed

+27
-23
lines changed

1 file changed

+27
-23
lines changed

src/Symfony/Bridge/PhpUnit/bin/simple-phpunit

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,28 @@ EOPHP
7373

7474
}
7575

76+
$components = array();
7677
$cmd = array_map('escapeshellarg', $argv);
7778
$exit = 0;
7879

7980
if (isset($argv[1]) && 'symfony' === $argv[1] && !file_exists('symfony') && file_exists('src/Symfony')) {
8081
$argv[1] = 'src/Symfony';
8182
}
8283
if (isset($argv[1]) && is_dir($argv[1]) && !file_exists($argv[1].'/phpunit.xml.dist')) {
83-
array_shift($cmd);
84+
// Find Symfony components in plain php for Windows portability
85+
86+
$finder = new RecursiveDirectoryIterator($argv[1], FilesystemIterator::KEY_AS_FILENAME | FilesystemIterator::UNIX_PATHS);
87+
$finder = new RecursiveIteratorIterator($finder);
88+
$finder->setMaxDepth(getenv('SYMFONY_PHPUNIT_MAX_DEPTH') ?: 3);
89+
90+
foreach ($finder as $file => $fileInfo) {
91+
if ('phpunit.xml.dist' === $file) {
92+
$components[] = dirname($fileInfo->getPathname());
93+
}
94+
}
95+
if ($components) {
96+
array_shift($cmd);
97+
}
8498
}
8599

86100
$cmd[0] = sprintf('%s %s --colors=always', $PHP, escapeshellarg("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit"));
@@ -92,34 +106,24 @@ if ('\\' === DIRECTORY_SEPARATOR) {
92106
$cmd .= '%2$s';
93107
}
94108

95-
if (isset($argv[1]) && is_dir($argv[1]) && !file_exists($argv[1].'/phpunit.xml.dist')) {
96-
// Find Symfony components in plain php for Windows portability
97-
98-
$finder = new RecursiveDirectoryIterator($argv[1], FilesystemIterator::KEY_AS_FILENAME | FilesystemIterator::UNIX_PATHS);
99-
$finder = new RecursiveIteratorIterator($finder);
100-
$finder->setMaxDepth(getenv('SYMFONY_PHPUNIT_MAX_DEPTH') ?: 3);
101-
109+
if ($components) {
102110
$skippedTests = isset($_SERVER['SYMFONY_PHPUNIT_SKIPPED_TESTS']) ? $_SERVER['SYMFONY_PHPUNIT_SKIPPED_TESTS'] : false;
103111
$runningProcs = array();
104112

105-
foreach ($finder as $file => $fileInfo) {
106-
if ('phpunit.xml.dist' === $file) {
107-
$component = dirname($fileInfo->getPathname());
113+
foreach ($components as $component) {
114+
// Run phpunit tests in parallel
108115

109-
// Run phpunit tests in parallel
110-
111-
if ($skippedTests) {
112-
putenv("SYMFONY_PHPUNIT_SKIPPED_TESTS=$component/$skippedTests");
113-
}
116+
if ($skippedTests) {
117+
putenv("SYMFONY_PHPUNIT_SKIPPED_TESTS=$component/$skippedTests");
118+
}
114119

115-
$c = escapeshellarg($component);
120+
$c = escapeshellarg($component);
116121

117-
if ($proc = proc_open(sprintf($cmd, $c, " > $c/phpunit.stdout 2> $c/phpunit.stderr"), array(), $pipes)) {
118-
$runningProcs[$component] = $proc;
119-
} else {
120-
$exit = 1;
121-
echo "\033[41mKO\033[0m $component\n\n";
122-
}
122+
if ($proc = proc_open(sprintf($cmd, $c, " > $c/phpunit.stdout 2> $c/phpunit.stderr"), array(), $pipes)) {
123+
$runningProcs[$component] = $proc;
124+
} else {
125+
$exit = 1;
126+
echo "\033[41mKO\033[0m $component\n\n";
123127
}
124128
}
125129

0 commit comments

Comments
 (0)