Skip to content

Start the cold run of the warm-rewrite test in a new second - #6697

Merged
ondrejmirtes merged 1 commit into
phpstan:2.3.xfrom
SanderMuller:fix-warm-rewrite-test-flake
Oct 7, 2026
Merged

ondrejmirtes merged 1 commit into
phpstan:2.3.xfrom
SanderMuller:fix-warm-rewrite-test-flake

Conversation

@SanderMuller

Copy link
Copy Markdown
Contributor

testWarmAnalysisDoesNotRewriteUnchangedResultCache fails often in "Integration tests", for example on #6694 and #6690. The warm run reports "Result cache restored. 0 files will be reanalysed." and then rewrites the result cache.

The cause is the clock second. FileStatSignatureReader gives no signature to a file modified in the second the analysis starts. setUp() writes the files, and the cold run usually starts in the same second, so it saves the result cache without signatures. The warm run starts in a later second, records the signatures, and rewrites the cache because they differ from the saved ones (fileStatSignaturesDiffer()). That is the intended behaviour, so the fix is in the test: it waits for the next second before the cold run. This adds at most one second to the test.

Verification, locally on 5f76acd:

  • Without the change, the test failed in 8 of 10 runs.
  • With the change, it passed in 20 of 20 runs, and the whole ResultCacheInfoCommandTest passed 3 times.
  • make phpstan reports no errors, and phpcs passes on the test file.

🤖 Generated with Claude Code

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>
@ondrejmirtes
ondrejmirtes merged commit 3bc56e3 into phpstan:2.3.x Oct 7, 2026
614 checks passed
@ondrejmirtes

Copy link
Copy Markdown
Member

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants