Repository navigation
Let the root PSR-4 e2e test start its unchanged-cache run a second after the files were written - #7074
Merged
Conversation
…ter the files were written A run does not record the stat signature of a file modified in the second it started, so when write_class_consumer's run started in the second its files were written, the next run records the signatures and rewrites the result cache, and 'Result cache was not rewritten because it is unchanged.' was missing intermittently. Amp-Thread-ID: https://ampcode.com/threads/T-01a1976c-1bde-72f8-b96c-072279109d59
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Class appears under a psr4 namespace mapped to the project root(e2e/result-cache-autoload-entries, added in603c305a6) fails intermittently. It failed on pushca825b09e(run 43579878816) and on two unrelated PR runs (43591616653, 43648464066). That's 3 failures in about 87 E2E runs since 11-13, and later runs of the same commits' successors pass. The signature is always the same:Root cause. The code isn't wrong; the test's timing is.
FileStatSignatureReaderdoesn't vouch for a file modified in the second the run started (the racy-git rule), so it leaves that file's signature out.write_class_consumerwritessrc/Consumer.phpandsrc/Unrelated.phpand runs PHPStan right away. On a fast runner that run sometimes starts in the same second. Then the next run is the first one that can record their signatures, sofileStatSignaturesDiffer()correctly rewrites the cache, and the assertion fails.Fix. The test waits one second and runs once more before the run that checks the cache is left unchanged. That run still covers what the test is for: PHPStan's own files in the tmpDir under a PSR-4 root don't count as changed scanned files, because the extra run rewrites
tmp/resultCache.phpright before it. Only the test changes.Verification (local, bashunit 0.52.0 as in CI):
write_class_consumer's analyse underfaketimepinned to the write second. Without the fix the test fails 3 of 3 times with the CI signature, and with the fix it passes 3 of 3.e2e/result-cache-autoload-entriesfile passes: 10 tests, 173 assertions.Shipped code is unchanged, so the downgraded PHAR's PHP 7.4 compatibility is unaffected.