updated streamline-setup v2

This commit is contained in:
2025-01-15 08:53:49 -08:00
committed by alec.turner
parent a2ce9248f0
commit 4b569f81b0
20228 changed files with 2932048 additions and 63204 deletions
@@ -13,9 +13,10 @@
namespace PHP_CodeSniffer\Tests\Standards;
use DirectoryIterator;
use PHP_CodeSniffer\Exceptions\RuntimeException;
use PHP_CodeSniffer\Ruleset;
use PHP_CodeSniffer\Files\LocalFile;
use PHP_CodeSniffer\Ruleset;
use PHP_CodeSniffer\Tests\ConfigDouble;
use PHP_CodeSniffer\Util\Common;
use PHPUnit\Framework\TestCase;
@@ -78,7 +79,7 @@ abstract class AbstractSniffUnitTest extends TestCase
$testFiles = [];
$dir = substr($testFileBase, 0, strrpos($testFileBase, DIRECTORY_SEPARATOR));
$di = new \DirectoryIterator($dir);
$di = new DirectoryIterator($dir);
foreach ($di as $file) {
$path = $file->getPathname();
@@ -192,10 +193,13 @@ abstract class AbstractSniffUnitTest extends TestCase
$fixedFile = $testFile.'.fixed';
$filename = basename($testFile);
if (file_exists($fixedFile) === true) {
$diff = $phpcsFile->fixer->generateDiff($fixedFile);
if (trim($diff) !== '') {
$fixedFilename = basename($fixedFile);
$failureMessages[] = "Fixed version of $filename does not match expected version in $fixedFilename; the diff is\n$diff";
if ($phpcsFile->fixer->getContents() !== file_get_contents($fixedFile)) {
// Only generate the (expensive) diff if a difference is expected.
$diff = $phpcsFile->fixer->generateDiff($fixedFile);
if (trim($diff) !== '') {
$fixedFilename = basename($fixedFile);
$failureMessages[] = "Fixed version of $filename does not match expected version in $fixedFilename; the diff is\n$diff";
}
}
} else if (is_callable([$this, 'addWarning']) === true) {
$this->addWarning("Missing fixed version of $filename to verify the accuracy of fixes, while the sniff is making fixes against the test case file");
@@ -9,10 +9,12 @@
namespace PHP_CodeSniffer\Tests\Standards;
use PHP_CodeSniffer\Util\Standards;
use PHP_CodeSniffer\Autoload;
use PHPUnit\TextUI\TestRunner;
use PHP_CodeSniffer\Util\Standards;
use PHPUnit\Framework\TestSuite;
use PHPUnit\TextUI\TestRunner;
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;
class AllSniffs
{
@@ -46,8 +48,6 @@ class AllSniffs
$suite = new TestSuite('PHP CodeSniffer Standards');
$isInstalled = !is_file(__DIR__.'/../../autoload.php');
// Optionally allow for ignoring the tests for one or more standards.
$ignoreTestsForStandards = getenv('PHPCS_IGNORE_TESTS');
if ($ignoreTestsForStandards === false) {
@@ -71,7 +71,7 @@ class AllSniffs
continue;
}
$di = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($testsDir));
$di = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($testsDir));
foreach ($di as $file) {
// Skip hidden files.