diff --git a/src/Plugins/Tia/Fingerprint.php b/src/Plugins/Tia/Fingerprint.php
index 39e56239..062e852e 100644
--- a/src/Plugins/Tia/Fingerprint.php
+++ b/src/Plugins/Tia/Fingerprint.php
@@ -5,7 +5,8 @@ declare(strict_types=1);
namespace Pest\Plugins\Tia;
use Pest\Plugins\Tia\Contracts\Lockfile;
-use Symfony\Component\Finder\Finder;
+use Symfony\Component\Process\Exception\ExceptionInterface as ProcessException;
+use Symfony\Component\Process\Process;
/**
* @internal
@@ -279,13 +280,16 @@ final readonly class Fingerprint
return $cache[$key] = true;
}
- $finder = (new Finder)
- ->in($projectRoot)
- ->depth('== 0')
- ->name($relativePath)
- ->ignoreVCSIgnored(true);
+ $process = new Process(['git', 'check-ignore', '-q', '--', $relativePath], $projectRoot);
+ $process->setTimeout(5.0);
- return $cache[$key] = $finder->hasResults();
+ try {
+ $process->run();
+ } catch (ProcessException) {
+ return $cache[$key] = true;
+ }
+
+ return $cache[$key] = $process->getExitCode() !== 0;
}
private static function contentHashOrNull(string $path): ?string
diff --git a/tests/.snapshots/success.txt b/tests/.snapshots/success.txt
index 4ba69a1a..871b52df 100644
--- a/tests/.snapshots/success.txt
+++ b/tests/.snapshots/success.txt
@@ -1942,6 +1942,11 @@
✓ keysWithPrefix() → it lists keys matching the prefix
✓ keysWithPrefix() → it ignores in-flight temporary files from concurrent writes
+ PASS Tests\Unit\Plugins\Tia\Fingerprint
+ ✓ compute() → it fingerprints tracked structural files in a regular clone
+ ✓ compute() → it fingerprints tracked structural files inside a linked git worktree
+ ✓ compute() → it excludes gitignored untracked files from the fingerprint
+
PASS Tests\Unit\Plugins\Tia\Graph
✓ shouldRerunStatus() → it re-runs failures and errors, replays successes
✓ applyMigrationChanges() → it selects tests whose recorded tables intersect the changed migration
@@ -2325,4 +2330,4 @@
✓ pass with dataset with ('my-datas-set-value')
✓ within describe → pass with dataset with ('my-datas-set-value')
- Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 40 todos, 37 skipped, 1652 passed (3655 assertions)
\ No newline at end of file
+ Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 40 todos, 37 skipped, 1655 passed (3663 assertions)
\ No newline at end of file
diff --git a/tests/Unit/Plugins/Tia/Fingerprint.php b/tests/Unit/Plugins/Tia/Fingerprint.php
new file mode 100644
index 00000000..734d7c44
--- /dev/null
+++ b/tests/Unit/Plugins/Tia/Fingerprint.php
@@ -0,0 +1,109 @@
+setTimeout(10.0);
+ $process->mustRun();
+}
+
+function fingerprintRepository(): string
+{
+ $root = sys_get_temp_dir().DIRECTORY_SEPARATOR.'pest_fingerprint_'.uniqid();
+ mkdir($root, 0777, true);
+
+ fingerprintGit($root, 'init', '-q');
+ fingerprintGit($root, 'config', 'user.email', 'pest@example.com');
+ fingerprintGit($root, 'config', 'user.name', 'Pest');
+
+ return $root;
+}
+
+function fingerprintRemoveDirectory(string $path): void
+{
+ if (! is_dir($path)) {
+ return;
+ }
+
+ $iterator = new RecursiveIteratorIterator(
+ new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS),
+ RecursiveIteratorIterator::CHILD_FIRST,
+ );
+
+ foreach ($iterator as $file) {
+ @chmod($file->getPathname(), 0777);
+ $file->isDir() ? @rmdir($file->getPathname()) : @unlink($file->getPathname());
+ }
+
+ @rmdir($path);
+}
+
+describe('compute()', function (): void {
+ it('fingerprints tracked structural files in a regular clone', function (): void {
+ $clone = fingerprintRepository();
+
+ try {
+ file_put_contents($clone.'/composer.lock', '{"packages": []}');
+ file_put_contents($clone.'/phpunit.xml', '');
+ fingerprintGit($clone, 'add', '-A');
+ fingerprintGit($clone, 'commit', '-q', '-m', 'init');
+
+ $fingerprint = Fingerprint::compute($clone);
+
+ expect($fingerprint['structural']['composer_lock'])->not->toBeNull()
+ ->and($fingerprint['structural']['phpunit_xml'])->not->toBeNull();
+ } finally {
+ fingerprintRemoveDirectory($clone);
+ }
+ });
+
+ it('fingerprints tracked structural files inside a linked git worktree', function (): void {
+ $clone = fingerprintRepository();
+
+ try {
+ file_put_contents($clone.'/composer.lock', '{"packages": []}');
+ file_put_contents($clone.'/phpunit.xml', '');
+ file_put_contents($clone.'/.gitignore', ".worktrees/\n");
+ fingerprintGit($clone, 'add', '-A');
+ fingerprintGit($clone, 'commit', '-q', '-m', 'init');
+ fingerprintGit($clone, 'worktree', 'add', '-q', '.worktrees/feature');
+
+ $worktree = $clone.'/.worktrees/feature';
+
+ $cloneFingerprint = Fingerprint::compute($clone);
+ $worktreeFingerprint = Fingerprint::compute($worktree);
+
+ expect($worktreeFingerprint['structural']['composer_lock'])->not->toBeNull()
+ ->and($worktreeFingerprint['structural']['phpunit_xml'])->not->toBeNull()
+ ->and($worktreeFingerprint['structural']['composer_lock'])->toBe($cloneFingerprint['structural']['composer_lock'])
+ ->and($worktreeFingerprint['structural']['phpunit_xml'])->toBe($cloneFingerprint['structural']['phpunit_xml']);
+ } finally {
+ fingerprintRemoveDirectory($clone);
+ }
+ });
+
+ it('excludes gitignored untracked files from the fingerprint', function (): void {
+ $clone = fingerprintRepository();
+
+ try {
+ file_put_contents($clone.'/composer.lock', '{"packages": []}');
+ file_put_contents($clone.'/.gitignore', "phpunit.xml\n");
+ fingerprintGit($clone, 'add', '-A');
+ fingerprintGit($clone, 'commit', '-q', '-m', 'init');
+
+ file_put_contents($clone.'/phpunit.xml', '');
+
+ $fingerprint = Fingerprint::compute($clone);
+
+ expect($fingerprint['structural']['phpunit_xml'])->toBeNull()
+ ->and($fingerprint['structural']['composer_lock'])->not->toBeNull();
+ } finally {
+ fingerprintRemoveDirectory($clone);
+ }
+ });
+});
diff --git a/tests/Visual/Parallel.php b/tests/Visual/Parallel.php
index 024728a6..c4dce3fb 100644
--- a/tests/Visual/Parallel.php
+++ b/tests/Visual/Parallel.php
@@ -20,7 +20,7 @@ test('parallel', function () use ($run): void {
$output = $run('--exclude-group=integration');
$output = implode("\n", array_slice(explode("\n", (string) $output), -10));
- $expected = '2 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 29 skipped, 1624 passed (3579 assertions)';
+ $expected = '2 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 29 skipped, 1627 passed (3587 assertions)';
expect($output)
->toContain("Tests: {$expected}")