Skip to content

Conversation

@staabm
Copy link
Contributor

@staabm staabm commented Sep 8, 2023

to allow testing of the result-cache lets add a new env var a new cli option, which we can use to instruct phpstan to exit with code=2, when the result cache was not used

see phpstan/phpstan#9857 (comment)

partly reverts #2608


➜ bug8778 git:(bug8778) ../../phpstan clear-result-cache -q; ../../phpstan analyse -q ➜ bug8778 git:(bug8778) ../../../phpstan-src/bin/phpstan analyse -vvv --generate-baseline --fail-without-result-cache Note: Using configuration file /Users/staabm/workspace/phpstan/e2e/bug8778/phpstan.neon. Result cache not used because the metadata do not match. 2/2 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100% 1 sec/1 sec Result cache is saved. [OK] Baseline generated with 1 error. Used memory: 78 MB ➜ bug8778 git:(bug8778) echo $? 2 
staabm added a commit to staabm/phpstan that referenced this pull request Sep 8, 2023
@ondrejmirtes
Copy link
Member

I agree that the error formatter was the wrong direction. But instead of env variable, I'd prefer --fail-without-result-cache CLI option :)

@staabm
Copy link
Contributor Author

staabm commented Sep 8, 2023

here you are

➜ bug8778 git:(bug8778) ../../phpstan clear-result-cache -q; ../../phpstan analyse -q ➜ bug8778 git:(bug8778) ../../../phpstan-src/bin/phpstan analyse -vvv --generate-baseline --fail-without-result-cache Note: Using configuration file /Users/staabm/workspace/phpstan/e2e/bug8778/phpstan.neon. Result cache not used because the metadata do not match. 2/2 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100% 1 sec/1 sec Result cache is saved. [OK] Baseline generated with 1 error. Used memory: 78 MB ➜ bug8778 git:(bug8778) echo $? 2 
@ondrejmirtes ondrejmirtes merged commit 2cb2f07 into phpstan:1.10.x Sep 8, 2023
@ondrejmirtes
Copy link
Member

Thank you.

@staabm staabm deleted the fail-if-no-result-cache branch September 8, 2023 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants