#55652 closed task (blessed) (fixed)
Test tool and unit test improvements for 6.1
Reported by: | hellofromTonya | Owned by: | |
---|---|---|---|
Milestone: | 6.1 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Build/Test Tools | Keywords: | has-patch has-unit-tests commit |
Focuses: | Cc: |
Change History (245)
This ticket was mentioned in Slack in #core by sergey. View the logs.
3 years ago
This ticket was mentioned in PR #2782 on WordPress/wordpress-develop by SergeyBiryukov.
3 years ago
#8
- Keywords has-patch has-unit-tests added
This ticket was mentioned in PR #2784 on WordPress/wordpress-develop by desrosj.
3 years ago
#10
This is for testing an improvement to Slack notifications where workflow outcomes from pull requests with a head_ref containing trunk
.
Trac ticket: https://core.trac.wordpress.org/ticket/55652
This ticket was mentioned in PR #2453 on WordPress/wordpress-develop by jrfnl.
2 years ago
#15
Started this branch to debug a couple of tests (webp related) which are failing on PHP 5.6 when NOT run inside the Docker container, using a standard PHP 5.6 install.
This generally would indicate a missing @requires
tag or missing skip condition.
I've done a large test refactor for that particular test class as nearly all methods were testing using foreach()
loops instead of data providers, so it was impossible to see what was really failing.
While looking into this I found the following curiousities:
- A function which was changed in WP 3.5.0
wp_save_image_file()
, apparently also changed return type - frombool
toarray|WP_Error
(BC-break anyone ?) -, but the documentation does not reflect that.- Does nobody use the function ?
- Or if they do, how can it be that nobody noticed this in 25 major releases ?
- The failing tests are in part not actually testing what they should be testing and if tested this way, there seems to be some dependency on a particular (not necessarily standard) PHP compilation. I haven't been able to track down the exact difference or rather how to detect the difference, but the result is the failing tests.
Note: the last commit is very much WIP/debugging. The commits before that are valid improvements which can be (and should be) committed anyway.
Trac ticket: https://core.trac.wordpress.org/ticket/55652
This ticket was mentioned in Slack in #hosting-community by javier. View the logs.
2 years ago
SergeyBiryukov commented on PR #2453:
2 years ago
#29
Shall I rebase the PR ?
Not sure if that's necessary, the test improvement commits still seem to apply correctly :)
#45
@
2 years ago
Note: [53537] was a follow-up to [1120/tests] rather than [1061/tests].
This ticket was mentioned in Slack in #core by sergey. View the logs.
2 years ago
This ticket was mentioned in Slack in #core by sergey. View the logs.
2 years ago
This ticket was mentioned in PR #2926 on WordPress/wordpress-develop by desrosj.
2 years ago
#63
Trac ticket: https://core.trac.wordpress.org/ticket/55652
This ticket was mentioned in Slack in #core by jorbin. View the logs.
2 years ago
This ticket was mentioned in Slack in #core by sergey. View the logs.
2 years ago
This ticket was mentioned in Slack in #core-test by javier. View the logs.
2 years ago
This ticket was mentioned in Slack in #core by sergey. View the logs.
2 years ago
This ticket was mentioned in Slack in #core by sergey. View the logs.
2 years ago
This ticket was mentioned in PR #3062 on WordPress/wordpress-develop by SergeyBiryukov.
2 years ago
#104
Trac ticket:
#105
@
2 years ago
In 53824:
Tests: Simplify the list of global groups in object cache tests.
This list was not up to date due to missing blog_meta
group, and does not appear to be required for the tests to pass, as WP_UnitTestCase_Base::flush_cache()
adds the same list of groups, which is up to date.
Follow-up to [946/tests], [1332/tests], [40343], [42836], [53823].
This ticket was mentioned in PR #3127 on WordPress/wordpress-develop by jrfnl.
2 years ago
#118
Introduced in [38907] in response to Trac#38457.
In the set_up()
method, a copy would be made of the original value of the global $wp_theme_directories
variable and the intention was to restore that original value in the tear_down()
method after running each test.
Unfortunately, this was not implemented correctly.
- The backup is made to a function local variable in
set_up()
and not stored somewhere where it is accessible from thetear_down()
method. - The restoring then references a non-existent property to restore, which would effectively set the
$wp_theme_directories
global tonull
.
Fixed by declaring a private property, storing the backup in that private property and restoring from the same.
This bug was discovered while fixing (removing) the magic methods in the WP_UnitTestCase_Base
in an effort to improve compatibility with PHP 8.2.
Note: fixing the above bug _may_ cause other tests to fail if tests run _after_ this test would expect the global $wp_theme_directories
variable to be null
. If that's the case, I will separately submit any additional fixes needed for those tests.
Trac ticket: https://core.trac.wordpress.org/ticket/55652
This ticket was mentioned in PR #3128 on WordPress/wordpress-develop by jrfnl.
2 years ago
#119
Introduced in [38832] in response to Trac#38373.
The $editor_id
property is declared as static
, so can only be approached as static, even when used within the same class in which the property is declared.
Using non-static access will result in null
. See: https://3v4l.org/93HQL
This PHP notice was hidden so far, due to the existence of magic methods in the WP_UnitTestCase_Base
class.
All the same, the magic methods as they were, would also return null
for this property.
All in all, the attachment being created for this test would never get the correct post_author
.
Fixed by using static access to approach the static
property.
This bug was discovered while fixing (removing) the magic methods in the WP_UnitTestCase_Base
in an effort to improve compatibility with PHP 8.2.
Trac ticket: https://core.trac.wordpress.org/ticket/55652
This ticket was mentioned in PR #3129 on WordPress/wordpress-develop by jrfnl.
2 years ago
#120
### Tests_Rewrite_OldDateRedirect::test_old_date_redirect_cache_invalidation(): bug fix [1]
Introduced in [53549] in response to Trac#36723.
The $post_id
property is declared as static
, so can only be approached as static, even when used within the same class in which the property is declared.
Using non-static access will result in null
. See: https://3v4l.org/93HQL
This PHP notice was hidden so far, due to the existence of magic methods in the WP_UnitTestCase_Base
class.
All the same, the magic methods as they were, would also return null
for this property.
All in all, the post being updated for this test would never get the correct post_id
.
Fixed by using static access to approach the static
property.
This bug was discovered while fixing (removing) the magic methods in the WP_UnitTestCase_Base
in an effort to improve compatibility with PHP 8.2.
### Tests_Rewrite_OldDateRedirect::test_old_date_redirect_cache_invalidation(): bug fix [2]
Introduced in [53549] in response to Trac#36723.
The previous bug fix (using the actual $post_id
instead of null
) exposed that this test was in actual fact failing. This was just hidden by the first bug.
Based on the original commit introducing the test, I gather the fix I'm applying now was what the test actually _intended_ to test, but it would be good to get confirmation of this from one of the original authors. /cc @spacedmonkey
Trac ticket: https://core.trac.wordpress.org/ticket/55652
#121
@
2 years ago
I've just opened three new PRs with bug fixes for the tests:
- Tests/Tests_Theme: fix bug in test set_up/tear_down
- WP_Test_REST_Attachments_Controller::test_update_item_parent(): bug fix
- Tests_Rewrite_OldDateRedirect::test_old_date_redirect_cache_invalidation(): bug fix x 2
These three are small PRs, but they are a prerequisite for the PHP 8.2 related PR removing the magic methods from the `WP_UnitTestCase_Base` class.
SergeyBiryukov commented on PR #3127:
2 years ago
#124
Thanks for the PR! Merged in r54040.
SergeyBiryukov commented on PR #3128:
2 years ago
#126
Thanks for the PR! Merged in r54041.
This ticket was mentioned in PR #3173 on WordPress/wordpress-develop by jrfnl.
2 years ago
#139
⚠️ This PR is a work in progress and will most likely be split into multiple PRs. For now, I've just opened the PR to keep track of the current state of things. ⚠️
Trac ticket:
This ticket was mentioned in PR #3173 on WordPress/wordpress-develop by jrfnl.
2 years ago
#140
⚠️ This PR is a work in progress and will most likely be split into multiple PRs. For now, I've just opened the PR to keep track of the current state of things. ⚠️
Trac ticket:
This ticket was mentioned in PR #3182 on WordPress/wordpress-develop by jrfnl.
2 years ago
#142
If the $files_that_shouldnt_exist
file list would be empty, this test would be marked as risky as it wouldn't perform any assertions.
This small tweak prevents this from happening.
Trac ticket: https://core.trac.wordpress.org/ticket/55652
This ticket was mentioned in PR #3183 on WordPress/wordpress-develop by jrfnl.
2 years ago
#143
This test verifies that the WordPress readme.html
file recommends a supported PHP version, however, WordPress currently still recommends PHP 7.4 due to PHP 8.0/8.1 compatibility not being fully achieved, even though PHP 7.4 is end-of-life.
As things were, the assertion in the test was commented out, leading to this test being marked as "risky" for performing any assertions.
Instead, let's skip the test with a clear skip notification.
Trac ticket: https://core.trac.wordpress.org/ticket/55652
#144
@
2 years ago
I've opened three new PRs related to this ticket:
- GH PR #3181 - GH Actions vs PHP 8.1 tweaks
- GH PR #3182 - Makes a test non-risky
- GH PR #3183 - Makes a test non-risky
Reviews/merges appreciated ;-)
SergeyBiryukov commented on PR #3182:
2 years ago
#149
Thanks for the PR! Merged in r54073.
SergeyBiryukov commented on PR #3183:
2 years ago
#151
Thanks for the PR! Merged in r54074.
SergeyBiryukov commented on PR #3129:
2 years ago
#154
Thanks for the PR! Merged in r54077, with a minor change for consistency with the related test for old slug redirects 🙂
2 years ago
#156
Merged in r54077, with a minor change for consistency with the related test for old slug redirects 🙂
Thanks @SergeyBiryukov ! Just checking: with your additional changes - is the test still testing what it should be testing ? (I haven't got time to verify at the moment, but my brain went into question mode when I looked at the adjusted commit...)
SergeyBiryukov commented on PR #3129:
2 years ago
#157
Just checking: with your additional changes - is the test still testing what it should be testing ?
I think so 🙂 My understanding of the intention if these tests is to verify that cache invalidation for _find_post_by_old_slug()
and _find_post_by_old_date()
functions works as expected. That is achieved by updating the post, thus changing the lookup query and the cache key.
There was a subtle difference in the test for old slug redirect, which updated the post and the cache key, but set the slug to the original value, so the permalink was not updated. In the test for old date redirect, the permalink was in fact updated, because the date was different. To avoid future confusion, I thought it would be a good idea to make these tests as consistent as possible, so they both update the permalink while clearing the cache, with the only difference that the test for old date redirect also changes the date (which it already did).
This ticket was mentioned in Slack in #core by sergey. View the logs.
2 years ago
This ticket was mentioned in Slack in #core by desrosj. View the logs.
2 years ago
This ticket was mentioned in PR #3349 on WordPress/wordpress-develop by desrosj.
2 years ago
#171
Trac ticket: https://core.trac.wordpress.org/ticket/55652
#174
@
2 years ago
Just wanted to add a bit of context around a scenario where [54342] would have been useful.
If a workflow is running, it cannot be restarted. The failed workflow recently encountered this edge case when the dispatched workflow started running before the original one was able to clean up after itself and finish.
This ticket was mentioned in Slack in #core by sergey. View the logs.
2 years ago
This ticket was mentioned in PR #3368 on WordPress/wordpress-develop by jrfnl.
2 years ago
#176
As it was, results of PHPCS runs would only ever show inline in a commit code view/PR code view.
This is confusing as people will often try to find an output log of the run in the GH Actions build log, not realizing the scan results are not available in the GH Actions log.
This commit changes the steps in the GH Actions workflows for both the PHPCS run against the WordPress Coding Standards as well as for the run against PHPCompatibility to show the full scan results report in the GH Actions logs _as well as_ show the results in commit/PR code views and still fail the build correctly when new issues are detected.
I've elected to store the (temporary) phpcs-report.xml
file in the artifacts
subdirectory as that directory is (git/svn)-ignored by default already to prevent this new, temporary file from interfering with the git diff
check at the end of the workflows.
Refs:
- https://github.com/staabm/annotate-pull-request-from-checkstyle#using-php_codesniffer
- https://github.com/WordPress/gutenberg/issues/44536#issuecomment-1261753524
Trac ticket: https://core.trac.wordpress.org/ticket/55652
#177
@
2 years ago
I've just opened PR GH #3368 to address confusion over where the results of PHPCS runs can be found.
Note: the PR contains two commits - only the first commit is intended to be used. The second is just there to demonstrate that the first commit works as intended.
#178
@
2 years ago
GitHub PR 3173 adds test skips for the last remaining PHP 8.1/8.2 issues to buy us time to address those later and removes the continue-on-error
from the GH Actions workflows so we can actively prevent new issues being introduced.
Reviewing and committing this at your earliest convenience would be appreciated.
2 years ago
#180
Can commit on Monday unless someone else beats me to it!
Sounds good to me! Thanks!
2 years ago
#181
I have rebased the PR after [54364] was committed, which means the first two commits are now gone.
The last commit skipping three tests for PHP 8.1 has been replaced with a commit applying @SergeyBiryukov's suggestion.
SergeyBiryukov commented on PR #2782:
2 years ago
#184
Merged in r54366.
SergeyBiryukov commented on PR #3173:
2 years ago
#186
Thanks for the PR! Merged in r54365 and r54369.
The REST API test issue was further investigated and resolved in r54368.
This ticket was mentioned in PR #3398 on WordPress/wordpress-develop by desrosj.
2 years ago
#191
Trac ticket: https://core.trac.wordpress.org/ticket/55652
#195
follow-ups:
↓ 196
↓ 203
@
2 years ago
@jrf and @desrosj:
A note regarding continue-on-error: true
in [54371], if issues arise:
I've recently had issues with that continue-on-error
(for the exact same use case of getting PHPCS output), as this apparently can lead to the "job" being marked as "passing" when the "step" however failed, and have since instead switched to using if: success() || failure()
in the step that calls cs2pr
.
#196
in reply to:
↑ 195
@
2 years ago
Replying to TobiasBg:
@jrf and @desrosj:
A note regarding
continue-on-error: true
in [54371], if issues arise:
I've recently had issues with that
continue-on-error
(for the exact same use case of getting PHPCS output), as this apparently can lead to the "job" being marked as "passing" when the "step" however failed, and have since instead switched to usingif: success() || failure()
in the step that callscs2pr
.
@TobiasBg Could you provide a little more detail about the specific situation in which it caused you problems ?
I mean, I have been using this two-step approach in dozens of projects and I have not seen any issues with it yet, so I'd like to understand if the issue you ran into applies to the WP workflow or not.
Also note: cs2pr
will exit with a non-zero exit code if the input file contains errors/warnings/notices. You can turn that off, but that's not being done in these workflows.
#197
@
2 years ago
@jrf: I can't seem to find the GH Actions run for my plugin where I had this problem, but I have some info from my commit message from the change:
GitHub Actions: Use a different way for executing steps after a previous step errors.
Usingcontinue-on-error
achieves the goal, but also lets jobs and workflows pass, which e.g.
leads to the problem that thefailed-workflow
step is not executed.
Theif
condition achieves this. Usingsuccess() || failure()
overalways()
has the
advantage that it still allows for builds to be cancelled.
(I had been working on copying that failed-workflow
enhancement that @desrosj added, as I'm often running into Github API issues, likely related to Composer.)
Now, indeed, if cs2pr
will give a non-0 exit code, things should actually be fine.
I'll try again with my change reverted, to see if I can trigger the wrong behavior again.
This ticket was mentioned in Slack in #core by sergey. View the logs.
2 years ago
#204
follow-up:
↓ 205
@
2 years ago
Is this maybe what you were thinking of @TobiasBg?
continue-on-error
is supported at the job and step level, but how these are reflected in the various UI locations is pretty inconsistent. Sometimes the entire workflow or job will show as failed, and others it will show as passing, even though a step failed.
#205
in reply to:
↑ 204
@
2 years ago
Replying to desrosj:
Is this maybe what you were thinking of @TobiasBg?
I hadn't seen that discussion yet, thanks for the link! Yes, my issues are in that direction, where jobs were marked as passing, while a step failed. (And I'm battling GitHub API rate limits a lot, even though I'm not really doing anything with them, besides a bit Composer ...)
#210
@
2 years ago
With RC1 later today, going to close this out. #56793 was created for 6.2.
If more required test changes come up during RC, then they can also make reference to this ticket.
This ticket was mentioned in PR #3516 on WordPress/wordpress-develop by @jrf.
2 years ago
#212
Follow up on PR #3368 and in particular @TobiasBg's remark in https://core.trac.wordpress.org/ticket/55652#comment:203
Ha! Found a situation which would allow the build to pass, even though the CS step would fail (but it would do so silently due to the continue-on-error
)
If there is a ruleset error, the cs2pr
action doesn't receive an xml
report and exits with a 0
error code, even though the PHPCS run failed (though not on CS errors, but on a ruleset error).
This changes the GH Actions workflow to allow for that situation and still fail the build in that case.
Trac ticket: https://core.trac.wordpress.org/ticket/55652
Trac ticket: https://core.trac.wordpress.org/ticket/56793
#215
@
2 years ago
- Keywords commit dev-feedback added
- Resolution fixed deleted
- Status changed from closed to reopened
Reopening so that [54674] can recieve a second sign off for backporting to the 6.1 branch.
2 years ago
#216
This looks good, though there is one thing I am wondering.
If the "Run PHPCS on all Core files" step fails, the corresponding cs2pr
step will still run. But I'm not sure that the "Check test suite files for warnings" and second cs2pr
step will also run if there's a preceding failure.
Should "Check test suite files for warnings" be updated to have an if: ${{ always() }}
conditional?
2 years ago
#217
If the "Run PHPCS on all Core files" step fails, the corresponding cs2pr step will still run. But I'm not sure that the "Check test suite files for warnings" and second cs2pr step will also run if there's a preceding failure.
They won't.
I get where you are coming from with this question, but that discussion is outside the scope of this PR.
This PR doesn't change that behaviour, the "test cs" check was always skipped if the "src cs" check failed. I didn't set it up like that 🤷🏻♀️
Should "Check test suite files for warnings" be updated to have an if: ${{ always() }} conditional?
If you want my advise on how to improve it, I would actually suggest adding a matrix
toggle and having one build running the "src cs" check and another the "test cs" check (using the same workflow, with both current steps getting a condition based on the toggle).
You could even add the PHPCompatibility check to the matrix as well then and get rid of the extra (duplicate) workflow.
Happy to help make that change, but, as I said, that's for another PR.
#221
in reply to:
↑ 220
;
follow-up:
↓ 222
@
2 years ago
Replying to desrosj:
Both [54674] and [54678] need a second committer sign off to backport.
As far as I see these changes are only to build/test functionality, not to "production" files. They will not affect how WP works, so don't think they need a second committer sign-off for backporting.
At the same time I don't see how the changes can be tested (locally). The only way seems to be to leave them in trunk for coupe days and see how they work. Perhaps can be backported after?
#222
in reply to:
↑ 221
;
follow-up:
↓ 226
@
2 years ago
- Keywords dev-feedback removed
Replying to azaozz:
As far as I see these changes are only to build/test functionality, not to "production" files. They will not affect how WP works, so don't think they need a second committer sign-off for backporting.
Ah, thanks. I honestly couldn't recall if build/test tool, tests, and docs were allowed without a double sign off. So wanted to follow the process to be safe.
At the same time I don't see how the changes can be tested (locally). The only way seems to be to leave them in trunk for coupe days and see how they work. Perhaps can be backported after?
Correct, these are GHA platform specific changes. I'm pretty confident in them, so I'll backport now. If follow up adjustments are needed, they can be included as part of #56882, which will backport a handful of other GHA related changes to older branches to ensure our workflows continue to run without issue going forward.
#226
in reply to:
↑ 222
@
2 years ago
Replying to desrosj:
I honestly couldn't recall if build/test tool, tests, and docs were allowed without a double sign off.
Yep, that part of the docs/handbook needs to be updated to make this clearer. As far as I know changes to tests, build/test tools, and inline comments (docblocks, etc.) do not require double sign-off. The reason is that these don't affect (directly) how the new release works in production.
A special case that does not require double sign-off are changes to the translatable strings. It is quite undesirable to change them as strings should be in string-freeze, but it's still possible. Usually these changes are mostly to fix a typo, etc.
In 53371: