mirror of
https://github.com/pestphp/pest.git
synced 2026-09-05 14:23:34 +02:00
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>
This commit is contained in:
committed by
GitHub
parent
fc17365bd1
commit
46df02dc28
@@ -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)
|
||||
@@ -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');
|
||||
});
|
||||
@@ -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}")
|
||||
|
||||
Reference in New Issue
Block a user