mirror of
https://github.com/pestphp/pest.git
synced 2026-09-05 14:23:34 +02:00
chore: upgrades to phpunit:13.3
This commit is contained in:
@@ -18,7 +18,7 @@ final class BootOverrides implements Bootstrapper
|
||||
public const array FILES = [
|
||||
'ParaTest/WrapperRunner/ProgressPrinterOutput.php',
|
||||
'Runner/Filter/NameFilterIterator.php',
|
||||
'Runner/ResultCache/DefaultResultCache.php',
|
||||
'Runner/TestRunHistory/DefaultTestRunHistory.php',
|
||||
'Runner/TestSuiteLoader.php',
|
||||
'Runner/TestSuiteSorter.php',
|
||||
'TextUI/Command/Commands/WarmCodeCoverageCacheCommand.php',
|
||||
|
||||
+10
-2
@@ -44,10 +44,18 @@ final class Cache implements HandlesArguments
|
||||
}
|
||||
}
|
||||
|
||||
if (! $this->hasArgument('--parallel', $arguments) && ! $this->hasArgument('--do-not-cache-result', $arguments) && ! $this->hasArgument('--cache-result', $arguments)) {
|
||||
return $this->pushArgument('--cache-result', $arguments);
|
||||
if (! $this->hasArgument('--parallel', $arguments) && ! $this->hasTestRunHistoryArgument($arguments)) {
|
||||
return $this->pushArgument('--record-test-run-history', $arguments);
|
||||
}
|
||||
|
||||
return $arguments;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, string> $arguments
|
||||
*/
|
||||
private function hasTestRunHistoryArgument(array $arguments): bool
|
||||
{
|
||||
return array_any(['--record-test-run-history', '--do-not-record-test-run-history', '--cache-result', '--do-not-cache-result'], fn (string $argument): bool => $this->hasArgument($argument, $arguments));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ final class Parallel implements HandlesArguments
|
||||
'-p',
|
||||
'--no-output',
|
||||
'--cache-result',
|
||||
'--record-test-run-history',
|
||||
];
|
||||
|
||||
public function handleArguments(array $arguments): array
|
||||
|
||||
@@ -21,7 +21,7 @@ use PHPUnit\Event\Facade as EventFacade;
|
||||
use PHPUnit\Event\Test\AfterLastTestMethodFailed;
|
||||
use PHPUnit\Event\TestRunner\WarningTriggered;
|
||||
use PHPUnit\Runner\CodeCoverage;
|
||||
use PHPUnit\Runner\ResultCache\DefaultResultCache;
|
||||
use PHPUnit\Runner\TestRunHistory\DefaultTestRunHistory;
|
||||
use PHPUnit\TestRunner\TestResult\Facade as TestResultFacade;
|
||||
use PHPUnit\TestRunner\TestResult\TestResult;
|
||||
use PHPUnit\TextUI\Configuration\CodeCoverageFilterRegistry;
|
||||
@@ -417,6 +417,9 @@ final class WrapperRunner implements RunnerInterface
|
||||
// @phpstan-ignore-next-line
|
||||
array_merge_recursive($testResultSum->phpWarnings(), $testResult->phpWarnings()),
|
||||
$testResultSum->numberOfIssuesIgnoredByBaseline() + $testResult->numberOfIssuesIgnoredByBaseline(),
|
||||
self::numberOfDeprecationsByTrigger($testResultSum, $testResult),
|
||||
// @phpstan-ignore-next-line
|
||||
array_merge_recursive($testResultSum->retriedTests(), $testResult->retriedTests()),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -455,14 +458,16 @@ final class WrapperRunner implements RunnerInterface
|
||||
$testResultSum->phpNotices(),
|
||||
$testResultSum->phpWarnings(),
|
||||
$testResultSum->numberOfIssuesIgnoredByBaseline(),
|
||||
self::numberOfDeprecationsByTrigger($testResultSum),
|
||||
$testResultSum->retriedTests(),
|
||||
);
|
||||
|
||||
self::$result = $testResultSum;
|
||||
|
||||
if ($this->options->configuration->cacheResult()) {
|
||||
$resultCacheSum = new DefaultResultCache($this->options->configuration->testResultCacheFile());
|
||||
if ($this->options->configuration->recordTestRunHistory()) {
|
||||
$resultCacheSum = new DefaultTestRunHistory($this->options->configuration->testRunHistoryFile());
|
||||
foreach ($this->resultCacheFiles as $resultCacheFile) {
|
||||
$resultCache = new DefaultResultCache($resultCacheFile->getPathname());
|
||||
$resultCache = new DefaultTestRunHistory($resultCacheFile->getPathname());
|
||||
$resultCache->load();
|
||||
|
||||
$resultCacheSum->mergeWith($resultCache);
|
||||
@@ -495,6 +500,28 @@ final class WrapperRunner implements RunnerInterface
|
||||
return $exitcode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{self: non-negative-int, direct: non-negative-int, indirect: non-negative-int, unknown: non-negative-int}
|
||||
*/
|
||||
private static function numberOfDeprecationsByTrigger(TestResult ...$results): array
|
||||
{
|
||||
$self = $direct = $indirect = $unknown = 0;
|
||||
|
||||
foreach ($results as $result) {
|
||||
$self += max(0, $result->numberOfSelfDeprecations());
|
||||
$direct += max(0, $result->numberOfDirectDeprecations());
|
||||
$indirect += max(0, $result->numberOfIndirectDeprecations());
|
||||
$unknown += max(0, $result->numberOfDeprecationsWithUnknownTrigger());
|
||||
}
|
||||
|
||||
return [
|
||||
'self' => $self,
|
||||
'direct' => $direct,
|
||||
'indirect' => $indirect,
|
||||
'unknown' => $unknown,
|
||||
];
|
||||
}
|
||||
|
||||
private function generateCodeCoverageReports(): void
|
||||
{
|
||||
if ($this->coverageFiles === []) {
|
||||
|
||||
@@ -57,7 +57,7 @@ final class CoverageMerger
|
||||
}
|
||||
|
||||
self::primeUncoveredFiles($cached);
|
||||
self::primeUncoveredFiles($current);
|
||||
self::discardUnexercisedFiles($current);
|
||||
|
||||
self::stripCurrentTestsFromCached($cached, $current);
|
||||
|
||||
@@ -77,6 +77,28 @@ final class CoverageMerger
|
||||
$coverage->getData(false);
|
||||
}
|
||||
|
||||
private static function discardUnexercisedFiles(CodeCoverage $coverage): void
|
||||
{
|
||||
$data = $coverage->getData(true);
|
||||
$lineCoverage = $data->lineCoverage();
|
||||
$discarded = false;
|
||||
|
||||
foreach ($lineCoverage as $file => $lines) {
|
||||
foreach ($lines as $hits) {
|
||||
if (is_array($hits) && $hits !== []) {
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
|
||||
unset($lineCoverage[$file]);
|
||||
$discarded = true;
|
||||
}
|
||||
|
||||
if ($discarded) {
|
||||
$data->setLineCoverage($lineCoverage);
|
||||
}
|
||||
}
|
||||
|
||||
private static function compress(string $bytes): string
|
||||
{
|
||||
$compressed = @gzencode($bytes);
|
||||
@@ -139,7 +161,7 @@ final class CoverageMerger
|
||||
*/
|
||||
private static function collectTestIds(CodeCoverage $coverage): array
|
||||
{
|
||||
$data = $coverage->getData();
|
||||
$data = $coverage->getData(true);
|
||||
$idByIndex = $data->testIds();
|
||||
|
||||
$ids = [];
|
||||
|
||||
Reference in New Issue
Block a user