diff --git a/src/Plugins/Tia.php b/src/Plugins/Tia.php index 578711e9..32c9a03e 100644 --- a/src/Plugins/Tia.php +++ b/src/Plugins/Tia.php @@ -14,7 +14,6 @@ use Pest\Plugins\Tia\Fingerprint; use Pest\Plugins\Tia\Graph; use Pest\Plugins\Tia\Recorder; use Pest\Plugins\Tia\ResultCollector; -use Pest\TestCaseFilters\TiaTestCaseFilter; use Pest\Plugins\Tia\WatchPatterns; use Pest\Support\Container; use Pest\TestSuite; @@ -435,7 +434,7 @@ final class Tia implements AddsOutput, BeforeEachable, HandlesArguments, Termina // the parent persisted, then install the per-file filter so // whichever tests paratest happens to hand this worker are // accepted / rejected consistently with the series path. - $this->installWorkerReplayFilter($projectRoot); + $this->installWorkerReplay($projectRoot); return $arguments; } @@ -458,7 +457,14 @@ final class Tia implements AddsOutput, BeforeEachable, HandlesArguments, Termina return $arguments; } - private function installWorkerReplayFilter(string $projectRoot): void + /** + * Wires worker-side replay. Mirrors the series path: sets `replayGraph` + * + `affectedFiles` so the `BeforeEachable` hook in `beforeEach()` can + * answer per-test. Unaffected tests replay their cached status (pass, + * fail, skip, todo, incomplete) so the user sees the full suite report + * in parallel runs exactly like in series. + */ + private function installWorkerReplay(string $projectRoot): void { $cachePath = self::cachePath(); $affectedPath = self::affectedPath(); @@ -489,9 +495,8 @@ final class Tia implements AddsOutput, BeforeEachable, HandlesArguments, Termina } } - TestSuite::getInstance()->tests->addTestCaseFilter( - new TiaTestCaseFilter($projectRoot, $graph, $affectedSet), - ); + $this->replayGraph = $graph; + $this->affectedFiles = $affectedSet; } /** diff --git a/src/TestCaseFilters/TiaTestCaseFilter.php b/src/TestCaseFilters/TiaTestCaseFilter.php deleted file mode 100644 index 682b31fd..00000000 --- a/src/TestCaseFilters/TiaTestCaseFilter.php +++ /dev/null @@ -1,65 +0,0 @@ - $affectedTestFiles Keys are project-relative test file paths. - */ - public function __construct( - private string $projectRoot, - private Graph $graph, - private array $affectedTestFiles, - ) {} - - public function accept(string $testCaseFilename): bool - { - $rel = $this->relative($testCaseFilename); - - if ($rel === null) { - return true; - } - - if (! $this->graph->knowsTest($rel)) { - return true; - } - - return isset($this->affectedTestFiles[$rel]); - } - - private function relative(string $path): ?string - { - $real = @realpath($path); - - if ($real === false) { - $real = $path; - } - - $root = rtrim($this->projectRoot, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR; - - if (! str_starts_with($real, $root)) { - return null; - } - - return str_replace(DIRECTORY_SEPARATOR, '/', substr($real, strlen($root))); - } -}