-
Notifications
You must be signed in to change notification settings - Fork 80
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
Update logic when deleting and uninstalling plugins #438
Conversation
9f18fb0
to
0c83ae6
Compare
Not sure what to do about the hook name linter which is not compatible with the legacy WordPress hook names:
|
…lugin(). Remove .10n.php files when removing language files. Do not count failed delete_plugins as successes, remove deleted plugins from plugin update list
0c83ae6
to
60d9786
Compare
Thanks for your PR, it's much appreciated!
WP-CLI uses Behat as its functional test suite. Functional tests are different than unit tests in that they execute the entire WP-CLI command, and ensure they always work as expected. Every repository has a See https://make.wordpress.org/cli/handbook/contributions/pull-requests/#running-and-writing-tests and https://www.youtube.com/playlist?list=PL_B8Y6K6MH2d6T7pYa6dloUgk67mfBT4K One example test would be to install a plugin, install its translations, then run |
Thanks @swissspidy Sorry, I think I was unintentionally using language around testing framework / style vs discussing what is actually tested. BDD is a totally fine approach. When I look at: https://github.com/wp-cli/extension-command/blob/main/features/plugin-uninstall.feature The only thing that checks something other than STDERR/STDOUT and the exit code is this test: https://github.com/wp-cli/extension-command/blob/main/features/plugin-uninstall.feature#L94-L114 There's no actual validation that any plugins have been installed, removed, what logic branches have been exercised, etc. Its definitely fine to take a functional style and agreed that one should focus on testing the interfaces that people interact with but what I was missing is a way to understand how to exercise the various logic branches in the changes I've made and to validate that things are "actually" happening (other than the files being present or not) because IMO, the presence of text on STDOUT/STDERR doesn't indicate anything other than a logic branch with the Not trying to be contrarian, just trying to make sure that I can be confident in the changes that I'm bringing to the project and help future contributors from not having to manually run WP CLI with all permutations to validate success. I'll dig more into Behat to see if there are ways to validate the underlying logic branches and confirm that they are being exercised. |
f30182b
to
ec280cb
Compare
I didn't see any tooling to run tests locally. Really sorry about using all these compute cycles on GitHub Actions to get these tests passing. Please let me know if there's tooling for local test runs so I can avoid wasting all this compute. Thanks! |
Seeing failed tests outside the scope of the PR: https://github.com/wp-cli/extension-command/blob/main/features/plugin-list-wporg-status.feature#L29
This seems odd as the test above has a different set of outputs for
Not sure how to proceed |
Looks like Behat is 3.7.0 which doesn't contain diff tooling from the latest versions.
^ Is this a whitespace issue? Is there a technique to understand how this doesn't match the test? These seem the same: https://github.com/wp-cli/extension-command/pull/438/files#diff-9817a156be3e1731243e8c1aafb2f74ce2d0b4e10a731cb4d4056273e9f7d550R44 |
You can also use other commands to verify that a plugin is no longer present, e.g. by verifying whether
Please check the https://make.wordpress.org/cli/handbook/contributions/pull-requests/#running-and-writing-tests link I shared before. Basically: Run Alternatively: use
Yes, looks like a newly failing test even on trunk, see https://github.com/wp-cli/extension-command/actions/runs/12247875028/job/34166552233#step:11:91 Please ignore it.
They have new diff features? Do you have a link? Because in wp-cli/wp-cli-tests#17 many years ago we were looking for that. Would be nice to finally fix this.
When you are expecting an issue, use Scenario: Missing required inputs
- When I run `wp plugin uninstall`
+ When I try `wp plugin uninstall` |
That makes sense. I'll add some additional testing to validate these scenarios using other wp cli commands
Ah thanks, sorry, I stopped reading at the Behat section. Apologies
10-4.
Yea, it was added in Behat/Behat#1532 It looks like there's a PR to introduce newer Behat that's blocked due to php version support: wp-cli/wp-cli-tests#228
Ah, thanks. Apologies again for being a newbie to all this stuff. |
@swissspidy this should be good to go. Thanks for all the help. I couldn't find a way to populate site transients so I removed that assertion:
but otherwise added some checks around more logic branches and file presence |
Looks like that's not in a tagged release yet, but maybe we can manually add these changes to our tooling or so. Thanks for pointing it out!
Amazing! Thank you for working on this!
|
Fixes: #437
delete_plugin
anddeleted_plugin
todelete_plugin()
delete_plugin()
.l10n.php
files when removing language files as per https://github.com/WordPress/WordPress/blob/e8b5d1a702e9fbf6a1f225df6501ea2e517938ec/wp-admin/includes/plugin.php#L1022Excuse my lack of tests and general ignorance of how to code on the WP CLI codebase. This is my first PR and I'm not seeing any testing like I would normally do for production projects:
a. Would update WordPress core to take any logic that's being copy/pasted into WP CLI and extract it into functions that can be called, rather than duplicating the logic as it would mean only 1 set of functions to maintain.
b. Would be create a set of table-driven tests to test all the logic branches of
uninstall()
which have spies to make sure that the appropriate WordPress core functions are called (or not) depending on the flags passedHowever, I don't know the logic and history behind why this codebase has duplicate logic. I'm not sure if there are stability concerns relying on core directly like that or other reason.
Let me know if there's ways I can improve the contribution and what levels of testing I can apply to make sure we have confidence in the current changes and to prevent regressions.
Thanks!