Added regression test for bug 8778#9857
Conversation
| composer dump | ||
| ../../phpstan clear-result-cache -vvv -q | ||
| ../../phpstan analyse -vvv -q | ||
| ! ../../phpstan analyse -vvv --generate-baseline 2>&1 | grep "Result cache not used because the metadata do not match" |
There was a problem hiding this comment.
we grep for the debug output and because of the leading ! of this line is the exit code of the last pipe inverted.
means we are getting only a successfull exit code, when the text was not matched
There was a problem hiding this comment.
This grep business can break really easily.
What I'd like instead:
- Add
isResultCacheUsedto AnalysisResult (pass$resultCache->isFullAnalysis()to the constructor) - Create
FailWithoutResultCacheErrorFormatter. After it checks that result cache was used, we can just callTableErrorFormatter. - Use this error formatter here in this test instead of
grep.
| composer dump | ||
| ../../phpstan clear-result-cache -vvv -q | ||
| ../../phpstan analyse -vvv --generate-baseline 2>&1 | ||
| ! ../../phpstan analyse -vvv -q | grep "Result cache not used because the metadata do not match" |
There was a problem hiding this comment.
added another test case, because I realized phpstan is also not using the result cache the other way arround
| composer dump | ||
| ../../phpstan clear-result-cache -vvv -q | ||
| ../../phpstan analyse -vvv -q | ||
| ! ../../phpstan analyse -vvv --generate-baseline 2>&1 | grep "Result cache not used because the metadata do not match" |
There was a problem hiding this comment.
This grep business can break really easily.
What I'd like instead:
- Add
isResultCacheUsedto AnalysisResult (pass$resultCache->isFullAnalysis()to the constructor) - Create
FailWithoutResultCacheErrorFormatter. After it checks that result cache was used, we can just callTableErrorFormatter. - Use this error formatter here in this test instead of
grep.
| composer dump | ||
| ../../phpstan clear-result-cache -q | ||
| ../../phpstan analyse -q | ||
| ../../phpstan analyse -vvv --generate-baseline --error-format=failWithoutResultCache |
There was a problem hiding this comment.
I just checked AnalyseCommand and the codepath with --generate-baseline actually isn't influenced by the selected error formatter. So this isn't going to fail.
I really like --error-format=failWithoutResultCache and am looking forward to use it in other E2E tests, but not sure what to do about it here.
There was a problem hiding this comment.
I had no better idea either. I went back using the grep way for the --generate-baseline case.
to make it more robust, I am doing a initial run, which does not expect the error message beeing in stdout and the subsequent run with the very same string.
hopefully thats good enough.
There was a problem hiding this comment.
Sleeping over it I got a different idea.
What about adding a new cli option, e.g --assert-result-cached or --fail-when-no-result-cache instead of using a error-formatter?
edit: maybe instead we could trigger it via ENV var, so the enduser won't see this testing-only infrastructure
There was a problem hiding this comment.
implemented a ENV var approach in phpstan/phpstan-src#2611
|
Thank you. |
covers #8778