-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[ci] Collect and replay skipped tests #16184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,7 @@ if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit")) { | |
// Build a standalone phpunit without symfony/yaml | ||
|
||
$oldPwd = getcwd(); | ||
mkdir($PHPUNIT_DIR); | ||
@mkdir($PHPUNIT_DIR); | ||
chdir($PHPUNIT_DIR); | ||
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')); | ||
|
@@ -41,7 +41,9 @@ if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit")) { | |
$zip->close(); | ||
chdir("phpunit-$PHPUNIT_VERSION"); | ||
passthru("$COMPOSER remove --no-update symfony/yaml"); | ||
passthru("$COMPOSER require --dev --no-update symfony/phpunit-bridge \">=2.8@dev\""); | ||
passthru("$COMPOSER install --prefer-source --no-progress --ansi"); | ||
symlink(realpath('../../src/Symfony/Bridge/PhpUnit/SkippedTestsListener.php'), './vendor/symfony/phpunit-bridge/SkippedTestsListener.php'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line should be removed before merging. For now, it allows testing before subtree-splitting |
||
chdir($oldPwd); | ||
} | ||
|
||
|
@@ -76,10 +78,13 @@ if ($phpIniMatrix) { | |
if (isset($argv[1]) && 'symfony' === $argv[1]) { | ||
// Find Symfony components in plain php for Windows portability | ||
|
||
$finder = new RecursiveDirectoryIterator(__DIR__.'/src/Symfony', FilesystemIterator::KEY_AS_FILENAME | FilesystemIterator::UNIX_PATHS); | ||
$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) { | ||
|
@@ -88,6 +93,10 @@ if (isset($argv[1]) && 'symfony' === $argv[1]) { | |
|
||
// 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)) { | ||
|
@@ -98,6 +107,7 @@ if (isset($argv[1]) && 'symfony' === $argv[1]) { | |
} | ||
} | ||
} | ||
chdir($oldPwd); | ||
|
||
// Fixes for colors support on appveyor | ||
// See https://github.com/appveyor/ci/issues/373 | ||
|
@@ -139,6 +149,9 @@ if (isset($argv[1]) && 'symfony' === $argv[1]) { | |
} | ||
unlink($file); | ||
} | ||
if ($skippedTests) { | ||
@unlink("$component/$skippedTests"); | ||
} | ||
|
||
if ($procStatus) { | ||
$exit = 1; | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?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\Bridge\PhpUnit; | ||
|
||
use Doctrine\Common\Annotations\AnnotationRegistry; | ||
|
||
/** | ||
* Collects and replays skipped tests. | ||
* | ||
* @author Nicolas Grekas <p@tchwork.com> | ||
*/ | ||
class SkippedTestsListener extends \PHPUnit_Framework_BaseTestListener | ||
{ | ||
private $state = -1; | ||
private $skippedFile = false; | ||
private $wasSkipped = array(); | ||
private $isSkipped = array(); | ||
|
||
public function __destruct() | ||
{ | ||
if (0 < $this->state) { | ||
file_put_contents($this->skippedFile, '<?php return '.var_export($this->isSkipped, true).';'); | ||
} | ||
} | ||
|
||
public function startTestSuite(\PHPUnit_Framework_TestSuite $suite) | ||
{ | ||
$suiteName = $suite->getName(); | ||
|
||
if (-1 === $this->state) { | ||
echo "Testing $suiteName\n"; | ||
$this->state = 0; | ||
|
||
if (!class_exists('Doctrine\Common\Annotations\AnnotationRegistry', false) && class_exists('Doctrine\Common\Annotations\AnnotationRegistry')) { | ||
AnnotationRegistry::registerLoader('class_exists'); | ||
} | ||
|
||
if ($this->skippedFile = getenv('SYMFONY_PHPUNIT_SKIPPED_TESTS')) { | ||
$this->state = 1; | ||
|
||
if (file_exists($this->skippedFile)) { | ||
$this->state = 2; | ||
|
||
if (!$this->wasSkipped = require $this->skippedFile) { | ||
exit("All tests already ran successfully.\n"); | ||
} | ||
} | ||
} | ||
} elseif (2 === $this->state) { | ||
$skipped = array(); | ||
foreach ($suite->tests() as $test) { | ||
if (!$test instanceof \PHPUnit_Framework_TestCase | ||
|| isset($this->wasSkipped[$suiteName]['*']) | ||
|| isset($this->wasSkipped[$suiteName][$test->getName()])) { | ||
$skipped[] = $test; | ||
} | ||
} | ||
$suite->setTests($skipped); | ||
} | ||
} | ||
|
||
public function addSkippedTest(\PHPUnit_Framework_Test $test, \Exception $e, $time) | ||
{ | ||
if (0 < $this->state) { | ||
if ($test instanceof \PHPUnit_Framework_TestCase) { | ||
$class = get_class($test); | ||
$method = $test->getName(); | ||
} else { | ||
$class = $test->getName(); | ||
$method = '*'; | ||
} | ||
|
||
$this->isSkipped[$class][$method] = 1; | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
20 minutes is twice the time required for tests to run. This prevents blocking for appveyor queue for too long.