This commit is contained in:
nuno maduro
2026-05-02 09:49:33 +01:00
parent 6407c4f78f
commit c38d32ae86
7 changed files with 155 additions and 32 deletions

View File

@ -516,13 +516,13 @@ final class Graph
/**
* @return array<int, string>
*/
public function failedOrErroredTestFiles(string $branch, string $fallbackBranch = 'main'): array
public function testFilesToRerun(string $branch, string $fallbackBranch = 'main'): array
{
$baseline = $this->baselineFor($branch, $fallbackBranch);
$files = [];
foreach ($baseline['results'] as $result) {
if ($result['status'] !== 7 && $result['status'] !== 8) {
if (! self::shouldRerun($result['status'])) {
continue;
}
@ -544,12 +544,12 @@ final class Graph
return array_keys($files);
}
public function hasUnlocatedFailuresOrErrors(string $branch, string $fallbackBranch = 'main'): bool
public function hasUnlocatedTestsToRerun(string $branch, string $fallbackBranch = 'main'): bool
{
$baseline = $this->baselineFor($branch, $fallbackBranch);
foreach ($baseline['results'] as $result) {
if ($result['status'] !== 7 && $result['status'] !== 8) {
if (! self::shouldRerun($result['status'])) {
continue;
}
@ -563,6 +563,16 @@ final class Graph
return false;
}
private static function shouldRerun(int $status): bool
{
$testStatus = TestStatus::from($status);
return $testStatus->isFailure()
|| $testStatus->isError()
|| $testStatus->isIncomplete()
|| $testStatus->isRisky();
}
/**
* @param array<string, string> $tree project-relative path → content hash
*/

View File

@ -119,8 +119,8 @@ final class Recorder
$this->perTestUsesDatabase[$file] = true;
}
$this->linkAncestorFiles($className);
$this->linkImportedFiles($file);
// $this->linkAncestorFiles($className);
// $this->linkImportedFiles($file);
if ($this->driver === 'pcov') {
\pcov\clear();
@ -175,7 +175,7 @@ final class Recorder
$this->perTestFiles[$this->currentTestFile][$sourceFile] = true;
}
$this->linkSourceDependencies($coveredFiles);
// $this->linkSourceDependencies($coveredFiles);
$this->currentTestFile = null;
$this->includedFilesAtTestStart = [];

View File

@ -4,6 +4,8 @@ declare(strict_types=1);
namespace Pest\Plugins\Tia;
use PHPUnit\Framework\TestStatus\TestStatus;
/**
* @internal
*/
@ -33,7 +35,7 @@ final class ResultCollector
return;
}
$this->record(0, '');
$this->record(TestStatus::success());
}
public function testFailed(string $message): void
@ -42,7 +44,7 @@ final class ResultCollector
return;
}
$this->record(7, $message);
$this->record(TestStatus::failure($message));
}
public function testErrored(string $message): void
@ -51,7 +53,7 @@ final class ResultCollector
return;
}
$this->record(8, $message);
$this->record(TestStatus::error($message));
}
public function testSkipped(string $message): void
@ -60,7 +62,7 @@ final class ResultCollector
return;
}
$this->record(1, $message);
$this->record(TestStatus::skipped($message));
}
public function testIncomplete(string $message): void
@ -69,7 +71,7 @@ final class ResultCollector
return;
}
$this->record(2, $message);
$this->record(TestStatus::incomplete($message));
}
public function testRisky(string $message): void
@ -78,7 +80,7 @@ final class ResultCollector
return;
}
$this->record(5, $message);
$this->record(TestStatus::risky($message));
}
/**
@ -121,7 +123,7 @@ final class ResultCollector
$this->startTime = null;
}
private function record(int $status, string $message): void
private function record(TestStatus $status): void
{
if ($this->currentTestId === null) {
return;
@ -134,8 +136,8 @@ final class ResultCollector
$existing = $this->results[$this->currentTestId] ?? null;
$this->results[$this->currentTestId] = [
'status' => $status,
'message' => $message,
'status' => $status->asInt(),
'message' => $status->message(),
'time' => $time,
'assertions' => $existing['assertions'] ?? 0,
];