Skip to content

Commit 3bc56e3

Browse files
SanderMullerclaude
authored andcommitted
Start the cold run of the warm-rewrite test in a new second
A file modified in the second the analysis starts gets no stat signature. When the cold run started in the second setUp() wrote the files, the warm run recorded the signatures and rewrote the result cache, so testWarmAnalysisDoesNotRewriteUnchangedResultCache failed. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent 5f76acd commit 3bc56e3

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎tests/PHPStan/Command/ResultCacheInfoCommandTest.php‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
use function md5;
1919
use function sprintf;
2020
use function sys_get_temp_dir;
21+
use function time;
2122
use function touch;
2223
use function uniqid;
24+
use function usleep;
2325
use const PHP_BINARY;
2426

2527
#[Group('exec')]
@@ -146,6 +148,11 @@ public function testChangedFileIsCountedAsFileToAnalyse(): void
146148

147149
public function testWarmAnalysisDoesNotRewriteUnchangedResultCache(): void
148150
{
151+
// a file modified in the second the analysis starts gets no stat signature, so a cold run in
152+
// the second setUp() wrote the files records none, and the warm run rewrites the cache to
153+
// record them
154+
$this->waitForNextSecond();
155+
149156
[$analyseOutput, $analyseExitCode] = $this->runPhpstan(['analyse', '--no-progress']);
150157
$this->assertSame(0, $analyseExitCode, $analyseOutput);
151158

@@ -210,6 +217,14 @@ public function testHumanReadableOutput(): void
210217
$this->assertStringContainsString('0 out of 2 files will be analysed.', $output);
211218
}
212219

220+
private function waitForNextSecond(): void
221+
{
222+
$second = time();
223+
while (time() === $second) {
224+
usleep(10_000);
225+
}
226+
}
227+
213228
/**
214229
* @param string[] $args
215230
* @return array{string, int}

0 commit comments

Comments
 (0)