Compare commits

..

3 Commits

Author SHA1 Message Date
nuno maduro e68976ea9d release: 5.1.4 2026-09-07 12:01:12 +01:00
Caleb White 17d709e32b chore: rector fixes (#1898) 2026-09-04 18:33:34 +05:30
Lazizbek Ergashev 46df02dc28 fix: key Tia worker partials per process to survive batch recycling (#1782)
* fix: key Tia worker partials per process to survive batch recycling

* test(tia): refresh visual snapshots for the worker token test

---------

Co-authored-by: Punyapal Shah <53343069+MrPunyapal@users.noreply.github.com>
2026-08-26 14:06:49 +05:30
12 changed files with 70 additions and 32 deletions
+11 -11
View File
@@ -25,13 +25,13 @@
"pestphp/pest-plugin-arch": "^5.0.0",
"pestphp/pest-plugin-mutate": "^5.0.2",
"pestphp/pest-plugin-profanity": "^5.0.0",
"phpunit/phpunit": "^13.3.1",
"symfony/process": "^8.1.5"
"phpunit/phpunit": "^13.3.2",
"symfony/process": "^8.1.6"
},
"conflict": {
"filp/whoops": "<2.18.3",
"laravel/boost": "<2.6.0",
"phpunit/phpunit": ">13.3.1",
"phpunit/phpunit": ">13.3.2",
"sebastian/exporter": "<7.0.0",
"webmozart/assert": "<1.11.0"
},
@@ -62,7 +62,7 @@
"require-dev": {
"pestphp/pest-dev-tools": "^5.0.0",
"pestphp/pest-plugin-browser": "^5.0.1",
"pestphp/pest-plugin-phpstan": "^5.2.0",
"pestphp/pest-plugin-phpstan": "^5.2.1",
"pestphp/pest-plugin-rector": "^5.0.4",
"pestphp/pest-plugin-type-coverage": "^5.0.2",
"psy/psysh": "^0.12.24"
@@ -89,15 +89,15 @@
"rector --dry-run",
"pint --parallel --test"
],
"test:profanity": "php bin/pest --profanity --compact",
"test:profanity": "XDEBUG_MODE=off php bin/pest --profanity --compact",
"test:type:check": "phpstan analyse --ansi --memory-limit=-1 --debug",
"test:type:coverage": "php -d memory_limit=-1 bin/pest --type-coverage --min=100",
"test:unit": "php bin/pest --exclude-group=integration --compact",
"test:inline": "php bin/pest --configuration=phpunit.inline.xml",
"test:parallel": "php bin/pest --exclude-group=integration --parallel --processes=3",
"test:integration": "php bin/pest --group=integration -v",
"test:type:coverage": "XDEBUG_MODE=off php -d memory_limit=-1 bin/pest --type-coverage --min=100",
"test:unit": "XDEBUG_MODE=off php bin/pest --exclude-group=integration --compact",
"test:inline": "XDEBUG_MODE=off php bin/pest --configuration=phpunit.inline.xml",
"test:parallel": "XDEBUG_MODE=off php bin/pest --exclude-group=integration --parallel --processes=3",
"test:integration": "XDEBUG_MODE=off php bin/pest --group=integration -v",
"test:tia": "php bin/pest --group=tia -v",
"update:snapshots": "REBUILD_SNAPSHOTS=true php bin/pest --update-snapshots --exclude-group=tia",
"update:snapshots": "XDEBUG_MODE=off REBUILD_SNAPSHOTS=true php bin/pest --update-snapshots --exclude-group=tia",
"test": [
"@test:lint",
"@test:type:check",
+4
View File
@@ -4,6 +4,7 @@ declare(strict_types=1);
use Pest\Rector\Rules\UseToMatchArrayRector;
use Pest\Rector\Set\PestSetList;
use Rector\CodeQuality\Rector\Isset_\IssetOnPropertyObjectToPropertyExistsRector;
use Rector\CodingStyle\Rector\ArrowFunction\ArrowFunctionDelegatingCallToFirstClassCallableRector;
use Rector\Config\RectorConfig;
use Rector\DeadCode\Rector\ClassMethod\RemoveDuplicatedReturnSelfDocblockRector;
@@ -51,6 +52,9 @@ return RectorConfig::configure()
AddArrowFunctionReturnTypeRector::class => [
__DIR__.'/tests',
],
IssetOnPropertyObjectToPropertyExistsRector::class => [
__DIR__.'/tests',
],
])
->withPreparedSets(
deadCode: true,
+1 -1
View File
@@ -6,7 +6,7 @@ namespace Pest;
function version(): string
{
return '5.1.3';
return '5.1.4';
}
function testDirectory(string $file = ''): string
+1 -3
View File
@@ -234,9 +234,7 @@ final class Shard implements AddsOutput, HandlesArguments, Terminable
$parts = explode('\\', $class);
$current = &$tree;
foreach ($parts as $part) {
if (! isset($current[$part])) {
$current[$part] = [];
}
$current[$part] ??= [];
$current = &$current[$part];
}
}
+3 -4
View File
@@ -1505,7 +1505,8 @@ final class Tia implements AddsOutput, HandlesArguments, HandlesOriginalArgument
private function workerToken(): string
{
$raw = $_SERVER['TEST_TOKEN'] ?? $_ENV['TEST_TOKEN'] ?? null;
$raw = $_SERVER['UNIQUE_TEST_TOKEN'] ?? $_ENV['UNIQUE_TEST_TOKEN']
?? $_SERVER['TEST_TOKEN'] ?? $_ENV['TEST_TOKEN'] ?? null;
$token = is_scalar($raw) ? (string) $raw : (string) getmypid();
$token = preg_replace('/[^A-Za-z0-9_-]/', '', $token);
@@ -1536,9 +1537,7 @@ final class Tia implements AddsOutput, HandlesArguments, HandlesOriginalArgument
foreach (['files', 'tables', 'inertia'] as $section) {
foreach ($data[$section] as $testFile => $values) {
if (! isset($merged[$section][$testFile])) {
$merged[$section][$testFile] = [];
}
$merged[$section][$testFile] ??= [];
foreach ($values as $value) {
$merged[$section][$testFile][$value] = true;
+2 -6
View File
@@ -1020,9 +1020,7 @@ final class Graph
private function ensureBaseline(string $branch): void
{
if (! isset($this->baselines[$branch])) {
$this->baselines[$branch] = ['sha' => null, 'tree' => [], 'results' => []];
}
$this->baselines[$branch] ??= ['sha' => null, 'tree' => [], 'results' => []];
}
/**
@@ -1067,9 +1065,7 @@ final class Graph
continue;
}
if (! isset($this->edges[$rel])) {
$this->edges[$rel] = [];
}
$this->edges[$rel] ??= [];
}
}
+1 -3
View File
@@ -111,9 +111,7 @@ final class Preset
*/
private function baseNamespaces(): array
{
if (self::$baseNamespaces === null) {
self::$baseNamespaces = Composer::userNamespaces();
}
self::$baseNamespaces ??= Composer::userNamespaces();
return self::$baseNamespaces;
}
@@ -1,5 +1,5 @@
Pest Testing Framework 5.1.3.
Pest Testing Framework 5.1.4.
USAGE: pest <file> [options]
@@ -1,3 +1,3 @@
Pest Testing Framework 5.1.3.
Pest Testing Framework 5.1.4.
+5 -1
View File
@@ -2061,6 +2061,10 @@
✓ it accepts a page directory candidate only when it matches the casing on disk with ('wrong parent')
✓ it accepts a page directory candidate only when it matches the casing on disk with ('absent')
PASS Tests\Unit\Plugins\Tia\WorkerToken
✓ prefers the per-process UNIQUE_TEST_TOKEN over the per-slot TEST_TOKEN, so two workers recycled into the same slot get different tokens
✓ falls back to TEST_TOKEN when UNIQUE_TEST_TOKEN is absent
PASS Tests\Unit\Preset
✓ preset invalid name
✓ preset → myFramework
@@ -2251,4 +2255,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, 35 skipped, 1596 passed (3481 assertions)
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 40 todos, 35 skipped, 1598 passed (3485 assertions)
+39
View File
@@ -0,0 +1,39 @@
<?php
use Pest\Plugins\Tia;
function tiaWorkerToken(): string
{
$tia = new ReflectionClass(Tia::class)->newInstanceWithoutConstructor();
return new ReflectionMethod($tia, 'workerToken')->invoke($tia);
}
beforeEach(function (): void {
unset(
$_SERVER['TEST_TOKEN'],
$_ENV['TEST_TOKEN'],
$_SERVER['UNIQUE_TEST_TOKEN'],
$_ENV['UNIQUE_TEST_TOKEN'],
);
});
test('prefers the per-process UNIQUE_TEST_TOKEN over the per-slot TEST_TOKEN, so two workers recycled into the same slot get different tokens', function (): void {
$_SERVER['TEST_TOKEN'] = '2';
$_SERVER['UNIQUE_TEST_TOKEN'] = '2_6a690d236824c';
$processA = tiaWorkerToken();
$_SERVER['UNIQUE_TEST_TOKEN'] = '2_9f31be04117a';
$processB = tiaWorkerToken();
expect($processA)->toBe('2_6a690d236824c')
->and($processB)->toBe('2_9f31be04117a')
->and($processA)->not->toBe($processB);
});
test('falls back to TEST_TOKEN when UNIQUE_TEST_TOKEN is absent', function (): void {
$_SERVER['TEST_TOKEN'] = '3';
expect(tiaWorkerToken())->toBe('3');
});
+1 -1
View File
@@ -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, 27 skipped, 1578 passed (3426 assertions)';
$expected = '2 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 27 skipped, 1580 passed (3430 assertions)';
expect($output)
->toContain("Tests: {$expected}")