-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[PhpUnitBridge] Add ability to set a baseline for deprecation testing #37733
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
Conversation
*/ | ||
public function isBaselineDeprecation(Deprecation $deprecation) | ||
{ | ||
$result = \in_array($deprecation->getMessage(), $this->baselineDeprecations, true); |
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.
So, we'll ignore any new occurence for a deprecation message.
Shouldn't we account for the number of occurrences for the baseline? As well as the class::method / triggering file?
The way this feature works in PHPStan is accounting at least for occurrences per class: https://medium.com/@ondrejmirtes/phpstans-baseline-feature-lets-you-hold-new-code-to-a-higher-standard-e77d815a5dff
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 agree with @ogizanagi, checking the count would be great.
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.
Thanks! Here are some comments.
src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Configuration.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Configuration.php
Outdated
Show resolved
Hide resolved
*/ | ||
public function isBaselineDeprecation(Deprecation $deprecation) | ||
{ | ||
$result = \in_array($deprecation->getMessage(), $this->baselineDeprecations, true); |
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 agree with @ogizanagi, checking the count would be great.
src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Configuration.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Configuration.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Configuration.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Configuration.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Configuration.php
Outdated
Show resolved
Hide resolved
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.
One CS issue + OK to fix @ogizanagi's comment?
As a reminder:
So, we'll ignore any new occurence for a deprecation message.
Shouldn't we account for the number of occurrences for the baseline? As well as the class::method / triggering file?The way this feature works in PHPStan is accounting at least for occurrences per class: medium.com/@ondrejmirtes/phpstans-baseline-feature-lets-you-hold-new-code-to-a-higher-standard-e77d815a5dff
@@ -87,6 +103,19 @@ private function __construct(array $thresholds = [], $regex = '', $verboseOutput | |||
} | |||
$this->verboseOutput[$group] = (bool) $status; | |||
} | |||
|
|||
if ($generateBaseline && !($baselineFile)) { |
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.
extra brackets should be removed :)
@alexpott Still interested in finishing this PR? |
f4c7577
to
3836618
Compare
@fabpot @nicolas-grekas @ogizanagi I've added the deprecation location and counting feature. It's pretty ugly but it works. Open to suggestions for improvements :) |
3836618
to
483236f
Compare
Thank you @alexpott. |
This PR allows you set new options for
SYMFONY_DEPRECATIONS_HELPER
env var:generateBaseline
- if this is set to TRUE any deprecations that occur will be written to the file defined in thebaselineFile
optionbaselineFile
a path to a file that contains a json encoded array of deprecations that will be skipped.Questions
generateBaseline
without also settingbaselineFile
an exception is thrown. We could use a default filename if one is not provided (like PHPStan).baselineFile
variable - should we check if it is readable or should we rely onfile_get_contents
()?Still @todo
Add proper end-to-end testing using a .phpt test