fix: package lock fingerprint

This commit is contained in:
nuno maduro
2026-07-18 01:10:01 +01:00
parent 9e79e491e2
commit 820fa08313
237 changed files with 2409 additions and 2100 deletions
+36 -37
View File
@@ -2,11 +2,11 @@
use Symfony\Component\Process\Process;
it('passes on first try', function () {
it('passes on first try', function (): void {
expect(true)->toBeTrue();
})->flaky();
it('passes on a subsequent try', function () {
it('passes on a subsequent try', function (): void {
$file = sys_get_temp_dir().'/pest_flaky_'.crc32(__FILE__.__LINE__);
$count = file_exists($file) ? (int) file_get_contents($file) : 0;
file_put_contents($file, (string) ++$count);
@@ -19,11 +19,11 @@ it('passes on a subsequent try', function () {
expect(true)->toBeTrue();
})->flaky(tries: 3);
it('has a default of 3 tries', function () {
it('has a default of 3 tries', function (): void {
expect(true)->toBeTrue();
})->flaky();
it('succeeds on the last possible try', function () {
it('succeeds on the last possible try', function (): void {
$file = sys_get_temp_dir().'/pest_flaky_last_try';
$count = file_exists($file) ? (int) file_get_contents($file) : 0;
file_put_contents($file, (string) ++$count);
@@ -36,11 +36,11 @@ it('succeeds on the last possible try', function () {
expect(true)->toBeTrue();
})->flaky(tries: 3);
it('works with tries of 1', function () {
it('works with tries of 1', function (): void {
expect(true)->toBeTrue();
})->flaky(tries: 1);
it('retries assertion failures', function () {
it('retries assertion failures', function (): void {
$file = sys_get_temp_dir().'/pest_flaky_assertion';
$count = file_exists($file) ? (int) file_get_contents($file) : 0;
file_put_contents($file, (string) ++$count);
@@ -53,11 +53,11 @@ it('retries assertion failures', function () {
expect(true)->toBeTrue();
})->flaky(tries: 3);
it('works with a dataset', function (int $number) {
it('works with a dataset', function (int $number): void {
expect($number)->toBeGreaterThan(0);
})->flaky(tries: 2)->with([1, 2, 3]);
it('retries each dataset independently', function (string $label) {
it('retries each dataset independently', function (string $label): void {
$file = sys_get_temp_dir().'/pest_flaky_dataset_'.md5($label);
$count = file_exists($file) ? (int) file_get_contents($file) : 0;
file_put_contents($file, (string) ++$count);
@@ -70,8 +70,8 @@ it('retries each dataset independently', function (string $label) {
expect(true)->toBeTrue();
})->flaky(tries: 3)->with(['alpha', 'beta']);
describe('within a describe block', function () {
it('retries inside describe', function () {
describe('within a describe block', function (): void {
it('retries inside describe', function (): void {
$file = sys_get_temp_dir().'/pest_flaky_describe';
$count = file_exists($file) ? (int) file_get_contents($file) : 0;
file_put_contents($file, (string) ++$count);
@@ -85,12 +85,12 @@ describe('within a describe block', function () {
})->flaky(tries: 2);
});
describe('lifecycle hooks with flaky', function () {
beforeEach(function () {
describe('lifecycle hooks with flaky', function (): void {
beforeEach(function (): void {
$this->setupCount = ($this->setupCount ?? 0) + 1;
});
it('re-runs beforeEach on each retry', function () {
it('re-runs beforeEach on each retry', function (): void {
$file = sys_get_temp_dir().'/pest_flaky_lifecycle';
$count = file_exists($file) ? (int) file_get_contents($file) : 0;
file_put_contents($file, (string) ++$count);
@@ -105,15 +105,15 @@ describe('lifecycle hooks with flaky', function () {
})->flaky(tries: 3);
});
describe('afterEach with flaky', function () {
describe('afterEach with flaky', function (): void {
$state = new stdClass;
$state->teardownCount = 0;
afterEach(function () use ($state) {
afterEach(function () use ($state): void {
$state->teardownCount++;
});
it('runs afterEach between retries', function () use ($state) {
it('runs afterEach between retries', function () use ($state): void {
$file = sys_get_temp_dir().'/pest_flaky_aftereach';
$count = file_exists($file) ? (int) file_get_contents($file) : 0;
file_put_contents($file, (string) ++$count);
@@ -132,7 +132,7 @@ it('does not retry skipped tests')
->skip('intentionally skipped')
->flaky(tries: 3);
it('works with repeat and flaky', function () {
it('works with repeat and flaky', function (): void {
expect(true)->toBeTrue();
})->repeat(times: 2)->flaky(tries: 2);
@@ -140,34 +140,33 @@ it('works as higher order test')
->assertTrue(true)
->flaky(tries: 2);
it('fails after exhausting all retries', function () {
it('fails after exhausting all retries', function (): void {
$process = new Process(
['php', 'bin/pest', 'tests/.tests/FlakyFailure.php'],
dirname(__DIR__, 2),
['COLLISION_PRINTER' => 'DefaultPrinter', 'COLLISION_IGNORE_DURATION' => 'true'],
['COLLISION_PRINTER' => 'DefaultPrinter', 'COLLISION_IGNORE_DURATION' => 'true', 'PAO_DISABLE' => '1'],
);
$process->run();
expect($process->getExitCode())->not->toBe(0);
expect(removeAnsiEscapeSequences($process->getOutput()))
->toContain('FAILED')
expect($process->getExitCode())->not->toBe(0)
->and(removeAnsiEscapeSequences($process->getOutput()))->toContain('FAILED')
->toContain('Always fails');
});
it('throws when tries is less than 1', function () {
it('invalid', function () {})->flaky(tries: 0);
it('throws when tries is less than 1', function (): void {
it('invalid', function (): void {})->flaky(tries: 0);
})->throws(InvalidArgumentException::class, 'The number of tries must be greater than 0.');
it('throws when tries is negative', function () {
it('invalid negative', function () {})->flaky(tries: -1);
it('throws when tries is negative', function (): void {
it('invalid negative', function (): void {})->flaky(tries: -1);
})->throws(InvalidArgumentException::class, 'The number of tries must be greater than 0.');
it('does not retry todo tests')
->todo()
->flaky(tries: 3);
it('retries php errors', function () {
it('retries php errors', function (): void {
$file = sys_get_temp_dir().'/pest_flaky_error';
$count = file_exists($file) ? (int) file_get_contents($file) : 0;
file_put_contents($file, (string) ++$count);
@@ -180,11 +179,11 @@ it('retries php errors', function () {
expect(true)->toBeTrue();
})->flaky(tries: 3);
it('works with throws and flaky', function () {
it('works with throws and flaky', function (): void {
throw new RuntimeException('Expected exception');
})->throws(RuntimeException::class, 'Expected exception')->flaky(tries: 2);
it('does not retry expected exceptions', function () {
it('does not retry expected exceptions', function (): void {
// If flaky retried this, the temp file counter would reach 2 and
// the test would NOT throw — causing PHPUnit's "expected exception
// was not raised" to fail. The test passes only if we don't retry.
@@ -204,11 +203,11 @@ it('does not retry expected exceptions', function () {
throw new RuntimeException('Expected on first attempt');
})->throws(RuntimeException::class)->flaky(tries: 3);
it('does not retry fails()', function () {
it('does not retry fails()', function (): void {
$this->fail('Expected failure');
})->fails('Expected failure')->flaky(tries: 2);
it('retries unexpected exceptions even with throws set', function () {
it('retries unexpected exceptions even with throws set', function (): void {
$file = sys_get_temp_dir().'/pest_flaky_unexpected';
$count = file_exists($file) ? (int) file_get_contents($file) : 0;
file_put_contents($file, (string) ++$count);
@@ -221,7 +220,7 @@ it('retries unexpected exceptions even with throws set', function () {
throw new RuntimeException('Expected exception');
})->throws(RuntimeException::class)->flaky(tries: 3);
it('does not leak mock objects between retries', function () {
it('does not leak mock objects between retries', function (): void {
$mock = $this->createMock(Countable::class);
$mock->expects($this->once())->method('count')->willReturn(1);
@@ -240,7 +239,7 @@ it('does not leak mock objects between retries', function () {
expect($mock->count())->toBe(1);
})->flaky(tries: 3);
it('does not stop retrying when snapshot changes are absent', function () {
it('does not stop retrying when snapshot changes are absent', function (): void {
// Ensures the snapshot guard only triggers when __snapshotChanges is non-empty
$file = sys_get_temp_dir().'/pest_flaky_no_snapshot';
$count = file_exists($file) ? (int) file_get_contents($file) : 0;
@@ -254,7 +253,7 @@ it('does not stop retrying when snapshot changes are absent', function () {
expect(true)->toBeTrue();
})->flaky(tries: 3);
it('does not leak dynamic properties between retries', function () {
it('does not leak dynamic properties between retries', function (): void {
$file = sys_get_temp_dir().'/pest_flaky_props';
$count = file_exists($file) ? (int) file_get_contents($file) : 0;
file_put_contents($file, (string) ++$count);
@@ -265,10 +264,10 @@ it('does not leak dynamic properties between retries', function () {
}
@unlink($file);
expect(isset($this->leakedProperty))->toBeFalse();
expect(property_exists($this, 'leakedProperty') && $this->leakedProperty !== null)->toBeFalse();
})->flaky(tries: 3);
it('clears output buffer between retries when expectOutputString is used', function () {
it('clears output buffer between retries when expectOutputString is used', function (): void {
$file = sys_get_temp_dir().'/pest_flaky_output';
$count = file_exists($file) ? (int) file_get_contents($file) : 0;
file_put_contents($file, (string) ++$count);
@@ -284,7 +283,7 @@ it('clears output buffer between retries when expectOutputString is used', funct
echo 'clean';
})->flaky(tries: 3);
it('preserves output between retries when no output expectation is set', function () {
it('preserves output between retries when no output expectation is set', function (): void {
$file = sys_get_temp_dir().'/pest_flaky_output_no_expect';
$count = file_exists($file) ? (int) file_get_contents($file) : 0;
file_put_contents($file, (string) ++$count);