-
Notifications
You must be signed in to change notification settings - Fork 13
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
Handling of configuration files #134
Comments
@anomiex PHPUnit offers a I think improving that I do feel your pain in this though, but there are more sticky issues around this as the PHPUnit 10.x I think this needs further discussion in the PHPUnit repo first. If you do open an issue there, please add the link to this ticket as I'd very much would like to follow the discussion. In the mean time, here are some links for interim solutions I've used in certain projects (take note of the info in the commit messages):
|
Thanks for pointing out that Someone already filed sebastianbergmann/phpunit#5199 about thee test runner exiting with a non-zero code on warnings even when Also I'm having a hard time coming up with a reason for wanting to ignore PHPUnit's own deprecation warnings but not PHP deprecation warnings that's more compelling than "we'd have to wait on upgrading phpunit until yoast/phpunit-polyfills gets a polyfill", except for the "deprecation" about an older-schema config file. I filed sebastianbergmann/phpunit#5405 for one actual bug I've encountered in the migration. I'm skeptical he'll consider failing to migrate |
@anomiex Thanks for that. I've subscribed to both issues. I hadn't gotten around to do a proper write-up of the issues myself yet.
Except that is not the real issue. There have been multiple times in the past when PHPUnit would warn about something being deprecated without replacement, only for it to be reconsidered and a replacement being added after all at a later point in time. This happened even as recently as PHPUnit 9.6 which warns about There are also warnings ("data providers have to be static") which don't necessarily affect the running of the test suite until a later point in time. Along the same lines as the reasoning for PHP deprecations, you may want to ignore those until those can be addressed as a managed mini-project, but that doesn't necessarily mean that PHP and PHPUnit deprecations should be addressed in the same mini-project or at the same time. They have a different time line and a different scope. Additionally, PHPUnit has recently had a tendency to change the configuration file a lot and to add deprecations in minor/patch versions which come out fairly regularly, which is very different from PHP, where such deprecations are only added once a year in a minor. What this means in practice is that, while for a new PHP version, you may add a CI build once a year with a In other words, the current PHPUnit 10.x XML attributes to manage warnings/deprecations etc just do not allow for updating PHPUnit related issues in a controlled way without blocking automatic use of the latest PHPUnit version. Does that clarify things a little more ? |
That's a good point, PHP does limit their deprecations to a new minor. And we (like probably everyone else) tend to treat minor PHP versions similarly to major versions of other stuff like PHPUnit. Sounds like you should handle filing the PHPUnit bug about this one, you have a much better grasp on the issue. 😉 |
FYI: in case you missed it: as of PHPUnit 10.5.32 and 11.3.3 PHPUnit deprecation notices are now decoupled from PHP deprecation notices, which should make live a hell of a lot easier. (still doesn't sort out the config, but does sort out some of the other things discussed above) |
PHPUnit 10 brings both several changes to the configuration file and a misfeature of causing
phpunit
to exit with a non-zero status if the config file does not strictly validate.So, for example, if you had been relying on
convert{X}ToExceptions="true"
, you might want to setdisplayDetailsOnTestsThatTrigger{X}="true"
andfailOn{X}="true"
for PHPUnit 10 to maintain that behavior going forward. But unless you also removeconvert{X}ToExceptions="true"
, changing the behavior for runs with earlier versions of PHP, PHPUnit 10 will whine about not recognizing the old setting and will exit with a failure status even if all actual tests pass.I don't know what the best way around this might be.
Simplest might be to provide a wrapper script that, if not passed
-c
or--configuration
or--no-configuration
, looks for various config file names and picks the best one for the current version of PHPUnit to set--configuration
before execingphpunit
. For example, it might check for any "phpunit.{VER}.xml.dist" and pick the one with the highest{VER}
that's not greater than PHPUnit's own version.A little fancier might be a wrapper that determines the configuration file in the same way PHPUnit would, copies it to a temporary file while stripping a predefined list of settings based on the PHPUnit version, and calls
phpunit
with--configuration
pointing to the temporary file.Unfortunately PHPUnit doesn't provide any way to hook into its own code to handle things more directly. There might still be ways, but they'd be fragile.
The text was updated successfully, but these errors were encountered: