mirror of
https://github.com/pestphp/pest.git
synced 2026-04-21 14:37:29 +02:00
wip
This commit is contained in:
@ -8,6 +8,7 @@ use Pest\Contracts\Plugins\AddsOutput;
|
||||
use Pest\Contracts\Plugins\HandlesArguments;
|
||||
use Pest\Contracts\Plugins\Terminable;
|
||||
use PHPUnit\Framework\TestStatus\TestStatus;
|
||||
use Pest\Plugins\Tia\BaselineSync;
|
||||
use Pest\Plugins\Tia\ChangedFiles;
|
||||
use Pest\Plugins\Tia\Contracts\State;
|
||||
use Pest\Plugins\Tia\CoverageCollector;
|
||||
@ -72,6 +73,8 @@ final class Tia implements AddsOutput, HandlesArguments, Terminable
|
||||
|
||||
private const string REBUILD_OPTION = '--tia-rebuild';
|
||||
|
||||
private const string PUBLISH_OPTION = '--tia-publish';
|
||||
|
||||
/**
|
||||
* State keys under which TIA persists its blobs. Kept here as constants
|
||||
* (rather than scattered strings) so the storage layout is visible in
|
||||
@ -195,6 +198,7 @@ final class Tia implements AddsOutput, HandlesArguments, Terminable
|
||||
private readonly CoverageCollector $coverageCollector,
|
||||
private readonly WatchPatterns $watchPatterns,
|
||||
private readonly State $state,
|
||||
private readonly BaselineSync $baselineSync,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@ -272,6 +276,16 @@ final class Tia implements AddsOutput, HandlesArguments, Terminable
|
||||
$recordingGlobal = $isWorker && (string) Parallel::getGlobal(self::RECORDING_GLOBAL) === '1';
|
||||
$replayingGlobal = $isWorker && (string) Parallel::getGlobal(self::REPLAYING_GLOBAL) === '1';
|
||||
|
||||
// `--tia-publish` is its own entry point: it neither records nor
|
||||
// replays, it just uploads whatever baseline is already on disk
|
||||
// and exits. Handled before the usual `--tia` gating so users can
|
||||
// publish without also triggering a suite run.
|
||||
if (! $isWorker && $this->hasArgument(self::PUBLISH_OPTION, $arguments)) {
|
||||
$projectRoot = TestSuite::getInstance()->rootPath;
|
||||
|
||||
exit($this->baselineSync->publish($projectRoot));
|
||||
}
|
||||
|
||||
$enabled = $this->hasArgument(self::OPTION, $arguments);
|
||||
$forceRebuild = $this->hasArgument(self::REBUILD_OPTION, $arguments);
|
||||
|
||||
@ -533,6 +547,25 @@ final class Tia implements AddsOutput, HandlesArguments, Terminable
|
||||
}
|
||||
}
|
||||
|
||||
// No local graph and not being forced to rebuild from scratch: try
|
||||
// to pull a team-shared baseline so fresh checkouts (new devs, CI
|
||||
// containers) don't pay the full record cost. If the pull succeeds
|
||||
// the graph is re-read and re-validated against the local env.
|
||||
if ($graph === null && ! $forceRebuild) {
|
||||
if ($this->baselineSync->fetchIfAvailable($projectRoot)) {
|
||||
$graph = $this->loadGraph($projectRoot);
|
||||
|
||||
if ($graph instanceof Graph && ! Fingerprint::matches($graph->fingerprint(), $fingerprint)) {
|
||||
$this->output->writeln(
|
||||
' <fg=yellow>TIA</> pulled baseline fingerprint mismatch — discarding.',
|
||||
);
|
||||
$this->state->delete(self::KEY_GRAPH);
|
||||
$this->state->delete(self::KEY_COVERAGE_CACHE);
|
||||
$graph = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Drop the marker so `Support\Coverage::report()` knows to merge the
|
||||
// current (narrow) coverage with the cached full-run snapshot. Plain
|
||||
// `--coverage` runs don't drop it, so their behaviour is untouched.
|
||||
|
||||
Reference in New Issue
Block a user