-
-
Notifications
You must be signed in to change notification settings - Fork 864
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added regression test for bug 8778 #9857
Conversation
.github/workflows/other-tests.yml
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This grep
business can break really easily.
What I'd like instead:
- Add
isResultCacheUsed
to 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
.
.github/workflows/other-tests.yml
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added another test case, because I realized phpstan is also not using the result cache the other way arround
.github/workflows/other-tests.yml
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This grep
business can break really easily.
What I'd like instead:
- Add
isResultCacheUsed
to 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
.
.github/workflows/other-tests.yml
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
implemented a ENV var approach in phpstan/phpstan-src#2611
Thank you. |
covers #8778