#61530 closed task (blessed) (fixed)
Test tool and unit test improvements for 6.7
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | 6.7 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Build/Test Tools | Keywords: | has-unit-tests has-patch |
Focuses: | Cc: |
Description (last modified by )
- #60705 (6.6)
- #59647 (6.5)
- #58955 (6.4)
- #57841 (6.3)
- #56793 (6.2)
- #55652 (6.1)
- #54725 (6.0)
- #53363 (5.9)
- #52625 (5.8)
- #51802 (5.7)
- #51344 (5.6)
This ticket is for various fixes and improvements in PHPUnit tests that don't have a more specific ticket, as well as general improvements to the GitHub Actions workflows that run automated testing.
Change History (93)
This ticket was mentioned in Slack in #core by jonsurrell. View the logs.
9 months ago
This ticket was mentioned in PR #6765 on WordPress/wordpress-develop by @jonsurrell.
9 months ago
#2
- Keywords has-patch has-unit-tests added
#3
@
9 months ago
- Component changed from HTML API to Build/Test Tools
- Description modified (diff)
- Summary changed from HTML API: Add more tests targeting 6.7 release to Test tool and unit test improvements for 6.7
- Type changed from enhancement to task (blessed)
@jonsurrell commented on PR #6765:
9 months ago
#4
Good suggestions, thanks @aaronjorbin. I've applied them.
This ticket was mentioned in PR #6765 on WordPress/wordpress-develop by @jonsurrell.
9 months ago
#5
Trac ticket: Core-61530
Add tests for comment handling.
These tests caught a regression during the 6.6 development cycle (with processing instruction comment tag name) that was fixed, but the tests were not merged.
This ticket was mentioned in PR #6765 on WordPress/wordpress-develop by @jonsurrell.
8 months ago
#7
Trac ticket: Core-61530
Add tests for comment handling.
These tests caught a regression during the 6.6 development cycle (with processing instruction comment tag name) that was fixed, but the tests were not merged.
@jonsurrell commented on PR #6765:
8 months ago
#8
Thanks @dmsnell, I applied those suggestions and cleaned things up. The signatures do become much simpler when we split the #comment
and #funky-comment
tests.
This ticket was mentioned in PR #6765 on WordPress/wordpress-develop by @jonsurrell.
8 months ago
#9
Trac ticket: Core-61530
Add tests for comment handling.
These tests caught a regression during the 6.6 development cycle (with processing instruction comment tag name) that was fixed, but the tests were not merged.
This ticket was mentioned in PR #6765 on WordPress/wordpress-develop by @jonsurrell.
8 months ago
#10
Trac ticket: Core-61530
Add tests for comment handling.
These tests caught a regression during the 6.6 development cycle (with processing instruction comment tag name) that was fixed, but the tests were not merged.
This ticket was mentioned in PR #6765 on WordPress/wordpress-develop by @jonsurrell.
8 months ago
#11
Trac ticket: Core-61530
Add tests for comment handling.
These tests caught a regression during the 6.6 development cycle (with processing instruction comment tag name) that was fixed, but the tests were not merged.
This ticket was mentioned in PR #7039 on WordPress/wordpress-develop by @jrf.
8 months ago
#12
The ${
syntax for string interpolation was deprecated in PHP 8.2 and should not be used anymore.
Ref: https://wiki.php.net/rfc/deprecate_dollar_brace_string_interpolation
Trac ticket: https://core.trac.wordpress.org/ticket/61530
Trac ticket: https://core.trac.wordpress.org/ticket/59654
#13
@
8 months ago
PR GH 7039 fixes a newly introduced PHP 8.2 deprecation notice.
This was not caught by running the tests as this is a deprecation notice which is thrown at compile time, not runtime.
#14
@
8 months ago
Patch: https://github.com/WordPress/wordpress-develop/pull/7039
Before this patch: the deprecation is thrown at the start of running the PHP 8.2+ tests ([see it here](https://github.com/WordPress/wordpress-develop/actions/runs/9957713967/job/27510405428#logs))
Not running external-http tests. To execute these, use --group external-http. Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /var/www/tests/phpunit/tests/html-api/wpHtmlProcessorHtml5lib.php on line 257 PHPUnit 9.6.20 by Sebastian Bergmann and contributors. Runtime: PHP 8.2.21
After this patch, the deprecation is no longer thrown ✅
Marking for and preparing the commit.
@hellofromTonya commented on PR #7039:
8 months ago
#16
Committed via https://core.trac.wordpress.org/changeset/58733.
This ticket was mentioned in PR #7040 on WordPress/wordpress-develop by @jrf.
8 months ago
#17
### Tests/wpInteractivityAPIFunctions: don't declare nested named function
Once the test_process_directives_when_block_is_filtered()
method has run, the named test_render_block_data()
function declared nested within becomes part of the global namespace, which could cause problems for other tests.
Quite apart from the fact that the name starting with test_
is confusing (as methods prefixed with test_
are supposed to be test methods to be run by PHPUnit).
Using a closure for this callback fixes the issue.
### Tests/test_wp_interactivity_data_wp_context_with_different_arrays(): use data provider
Refactor the test to use a data provider with named test cases.
This is better as:
- One failing test will not block the other tests from running.
- Each test is now referenced by name in any error message, making it more straight forward to see which test failed.
- The test no longer contains multiple assertions.
- It makes it more straight forward to add additional tests.
### Tests/test_wp_interactivity_data_wp_context_with_different_arrays_and_a_namespace(): use data provider
Refactor the test to use a data provider with named test cases.
This is better as:
- One failing test will not block the other tests from running.
- Each test is now referenced by name in any error message, making it more straight forward to see which test failed.
- The test no longer contains multiple assertions.
- It makes it more straight forward to add additional tests.
### Tests/test_wp_interactivity_data_wp_context_with_json_flags(): use data provider
Refactor the test to use a data provider with named test cases.
This is better as:
- One failing test will not block the other tests from running.
- Each test is now referenced by name in any error message, making it more straight forward to see which test failed.
- The test no longer contains multiple assertions.
- It makes it more straight forward to add additional tests.
Trac ticket: https://core.trac.wordpress.org/ticket/61530
#18
follow-up:
↓ 22
@
8 months ago
PR GH 7040 contains some stability and maintainability improvements for the InteractivityAPI tests.
This ticket was mentioned in PR #6765 on WordPress/wordpress-develop by @jonsurrell.
8 months ago
#21
Trac ticket: Core-61530
Add tests for comment handling.
These tests caught a regression during the 6.6 development cycle (with processing instruction comment tag name) that was fixed, but the tests were not merged.
@hellofromTonya commented on PR #7040:
8 months ago
#25
This ticket was mentioned in PR #7362 on WordPress/wordpress-develop by @jrf.
6 months ago
#33
Composer 1.10.0 introduced a lock
config option, which, when set to false
will prevent a composer.lock
file from being created and will ignore it when one exists.
This is a useful option for packages like WordPress where the lock
file has no meaning.
It also makes life more straight-forward for contributors as they don't have to remember that for this repo they should use composer update
instead of composer install
. Both will now work the same.
Refs:
https://getcomposer.org/doc/06-config.md#lock
Trac ticket: https://core.trac.wordpress.org/ticket/61530
#34
@
6 months ago
I've opened GH PR #7362 with a quality of life improvement for contributors using Composer to locally run the tests.
This ticket was mentioned in PR #7363 on WordPress/wordpress-develop by @jrf.
6 months ago
#35
Tests which can not run because a prerequisite is not fulfilled should be marked as "skipped", not as _failed_ (as they haven't failed, they didn't run).
Now, I can imagine the choice to mark the tests as "failed" may have been to prevent contributors missing the message about the need to install the Importer plugin. If that's the case, I'd suggest adding a file_exists()
check for the importer plugin to the test bootstrap.php
file and exiting the test run if that prerequisite is not fulfilled, along the same lines as the check that the database connection can be made and that the correct version of the Polyfills is installed.
I'll happily update the test bootstrap to add this, but would like some more opinions on whether or not this is really a necessity.
Trac ticket: https://core.trac.wordpress.org/ticket/61530
#36
@
6 months ago
I've opened GH PR #7363 to improve the output from PHPUnit by not marking tests which should be skipped due to an unfulfilled test requirement as failed.
This ticket was mentioned in PR #7364 on WordPress/wordpress-develop by @jrf.
6 months ago
#37
### WP_UnitTestCase_Base: introduce a new assertion and a new helper method
Introduces WP_UnitTestCase_Base::assertSamePathIgnoringDirectorySeparators()
and an associated helper method WP_UnitTestCase_Base::normalizeDirectorySeparatorsInPath()
to allow for comparing two file path strings independently of OS-specific differences.
The normalization is done in a separate method to also allow this method to be used for path normalization within test methods themselves, like for normalizing a group of paths in an array.
The pretty specific method name for the helper (normalizeDirectorySeparatorsInPath()
) is an attempt to prevent naming conflicts with methods which may exist in plugin test suites build on top of the WP Core test suite.
### Tests: start using the new assertion and helper method
Trac ticket: https://core.trac.wordpress.org/ticket/61530
#38
@
6 months ago
I've opened GH PR #7364 to stabilize some tests which would pass on *nix systems, but would structurally fail on Windows systems.
This is on the one hand a quality of life improvement for contributors on Windows running the PHPUnit tests locally. On the other hand, it paves the way towards being able to run the tests on Windows in CI at some point in the future.
This ticket was mentioned in PR #7365 on WordPress/wordpress-develop by @jrf.
6 months ago
#39
Trac ticket: https://core.trac.wordpress.org/ticket/61530
#40
@
6 months ago
I've opened GH PR #7365 with another two fixes to resolve test failures on Windows.
@hellofromTonya commented on PR #7365:
6 months ago
#42
Committed via https://core.trac.wordpress.org/changeset/59054 ✅
#43
@
6 months ago
Hmm, this changeset is not showing in Trac, but is in the build. Manually copying the details here for reference.
In 59057:
@hellofromTonya commented on PR #7364:
6 months ago
#45
- https://github.com/WordPress/wordpress-develop/pull/7364/commits/0e965d96ff42447ebd4c1858c777df7bcd933fdd committed via https://core.trac.wordpress.org/changeset/59057 ✅
- https://github.com/WordPress/wordpress-develop/pull/7364/commits/309ce819670e78072b074fa5cb8a8db22dd40583 committed via https://core.trac.wordpress.org/changeset/59061 ✅
@SergeyBiryukov commented on PR #7362:
6 months ago
#47
Thanks for the PR! Merged in r59082.
@SergeyBiryukov commented on PR #7363:
6 months ago
#50
Thanks for the PR! Merged in r59085.
#51
@
6 months ago
FYI, the latest PR merged has broken plugin integration testing following the instructions at https://make.wordpress.org/cli/handbook/misc/plugin-unit-tests/. See #62106 for details.
#52
follow-up:
↓ 58
@
6 months ago
@bjorsch I just checked and my first thought was adding a check for WP_RUN_CORE_TESTS
, but kudos to @SergeyBiryukov, that check is already in place in the patch as committed.
So the short of it, as far as I can see, is that plugin tests should not be broken by this commit. Plugin integration tests should not set the WP_RUN_CORE_TESTS
PHP constant, or if they do, it should be set to 0
.
Typically, the constant is set like below from the phpunit.xml[.dist]
file when running the Core tests.
<php> <const name="WP_RUN_CORE_TESTS" value="1" /> </php>
I've also done a test run with a plugin using integration tests with WP Core and the tests run just fine for the plugin I tested with.
I've also checked the template file used by the WP-CLI scaffold
command for the phpunit.xml.dist file and it also doesn't include the constant.
All in all, this sounds like a problem with the plugin integration test set up of that particular plugin, not with WP Core.
@bjorsch Could you please check for the tests where you noticed the failure that the constant is not being set ?
6 months ago
#53
Thanks @SergeyBiryukov! And thanks for adding the WP_RUN_CORE_TESTS
check to the condition too.
#54
@
6 months ago
Are there any updates required in the Gutenberg repo?
The PHP unit tests are failing with the following error, which corresponds to that committed in https://core.trac.wordpress.org/changeset/59085
[25-Sep-2024 04:06:39 UTC] PHP Warning: Constant WP_DEBUG already defined in /wordpress-phpunit/wp-tests-config.php on line 119 The test suite requires the WordPress Importer plugin to be available in the `/data/plugins/` directory. See: https://make.wordpress.org/core/handbook/contribute/git/#unit-tests
#55
@
6 months ago
@ramonopoly IF Gutenberg runs with WP_RUN_CORE_TESTS=1
, the first thing to do is figure out if that is actually the right setup. If yes: in that case, the importer plugin should be installed in the WP tests/phpunit/data/plugins
directory. If not: remove the constant or set it to 0
.
This is basically the same as my previous answer. The Core tests are set up to allow for plugin integration tests, but it is not Core's responsibility if those integration tests are not wired correctly.
#56
@
6 months ago
Note: if something else is going on and this is not related to the constant, please provide more information so we can figure out whether this needs to be reverted or changed. Based on the current info + patch, I see no reason for that, but new information may change that.
#57
@
6 months ago
Thanks for the quick reply and context @jrf
Gutenberg does have WP_RUN_CORE_TESTS
set to true in the phpunit bootstrap.php. If, after testing, any more info arises that's pertinent to this ticket I'll update, but it sounds like the fix is plugin-specific.
Thank you!
#58
in reply to:
↑ 52
@
6 months ago
Replying to jrf:
@bjorsch I just checked and my first thought was adding a check for
WP_RUN_CORE_TESTS
, but kudos to @SergeyBiryukov, that check is already in place in the patch as committed.
The check wasn't included in r59085, which was the latest when I wrote that comment. Sergey added it in r59086 to fix the problem I reported. 🙂
#59
follow-up:
↓ 60
@
6 months ago
@bjorsch Ah, yes, I only noticed that was a second commit after I replied. I presume I can conclude that solved it for you though ?
This ticket was mentioned in PR #7484 on WordPress/wordpress-develop by @peterwilsoncc.
6 months ago
#62
Additional tests for default themes:
- Ensure the zip test matrix includes all themes
- Ensure test suite and WP_Theme default lists match
- Ensure the constant matches the list in WP_Theme
Trac ticket: Core-61530
@peterwilsoncc commented on PR #7484:
6 months ago
#65
This ticket was mentioned in PR #7535 on WordPress/wordpress-develop by @peterwilsoncc.
5 months ago
#66
Trac ticket: Core-61530
This ticket was mentioned in PR #7553 on WordPress/wordpress-develop by @desrosj.
5 months ago
#68
This allows old versions to continue running E2E tests that require the Gutenberg plugin even after the minimum required version of Wordpress is increased for the plugin.
Trac ticket: https://core.trac.wordpress.org/ticket/61530
This ticket was mentioned in PR #7554 on WordPress/wordpress-develop by @desrosj.
5 months ago
#71
Trac ticket: https://core.trac.wordpress.org/ticket/61530
@peterwilsoncc commented on PR #7535:
5 months ago
#75
Merged r59227 / https://github.com/WordPress/wordpress-develop/commit/1dcbe1096e14347c0c9913ec9fb985622d9b1285
Anything for the actions can be added in a follow up.
#77
@
5 months ago
Hello,
Could someone review this PR https://github.com/WordPress/wordpress-develop/pull/4132?
I originally created it for ticket #56800 ("Reduce usage of assertEquals"), but I think it's more of an improvement.
Thanks.
#78
@
5 months ago
- Resolution set to fixed
- Status changed from new to closed
Hey @Rahmohn,
My apologies that we were unable to get that one over the finish line. RC1 is today for 6.7 so I'm going to close this one out. I've opened #62278 for the 6.8 cycle and updated your PR to reference that one instead.
That said, test updates can happen at any time, so if a committer has time to review before 6.7 is released, it can make it's way in attached to this ticket.
I've opened #62280 for test tool and unit test improvements in 6.8.
#79
@
5 months ago
- Resolution fixed deleted
- Status changed from closed to reopened
Just ran into the error: "The test suite requires the WordPress Importer plugin to be available in the /data/plugins/
directory." on a fresh git clone running wp-env.
Sorry but [59085] doesn't seem to make sense. Why is a WordPress plugin required to be present at an arbitrary location, not in the wp-content/plugins
directory, to be able to run unit tests? This seems contraintuitive, the PHP unit tests can be run only partially, or while developing a plugin, etc. It doesn't seem to make sense to prevent running any tests just because some non-core file is not present. Seems a better solution would be to skip any core tests that require external/extra files when they are not present?
Also if any external files are required when testing core, including any WP plugins, they should either be committed to the appropriate locations or added during building, just like all the image test files, etc. It doesn't make sense to require files to be added by hand. That seems pretty bad UX :)
Reopening as this ticket is a task and (maybe) can be fixed during RC too.
#81
follow-up:
↓ 86
@
5 months ago
@azaozz The test suite requiring the importer be in a defined location was always the case, if that changes it can be done so during the 6.8 cycle.
The change in [59085] changed how the tests failed, stalling the entire test suite rather than failing the individual tests.
For 6.7, let's consider whether we should revert back to failing only the individual tests rather than existing early. PR incoming for people to consider.
This ticket was mentioned in PR #7655 on WordPress/wordpress-develop by @peterwilsoncc.
5 months ago
#82
- Keywords has-patch added; needs-patch removed
Follow up to r59085.
Instead of preventing the test suite from running, only fail the import related tests if the plugin is not available.
Note, this puts a call to fail
in the setIUp
of several tests. It may need to be moved to each individual test if there is a risk that PHP Unit will stop accepting fail calls during the set up.
Trac ticket: Core-61530
#83
follow-up:
↓ 87
@
5 months ago
Related: #42668.
This focuses on removing the importer tests and only running them within the plugin's repository on GitHub instead, which seems like a better solution.
#84
follow-up:
↓ 85
@
5 months ago
@desrosj I agree but for 6.7 I think it would be handy to revert the change so the tests don't exit if the plugin is unavailable.
#85
in reply to:
↑ 84
@
5 months ago
Replying to peterwilsoncc:
@desrosj I agree but for 6.7 I think it would be handy to revert the change so the tests don't exit if the plugin is unavailable.
Sorry, that was not clear form my post. Was not advocating for tackling #42668 now and in favor of a revert or smaller change in the mean time for 6.7.
#86
in reply to:
↑ 81
@
5 months ago
Replying to peterwilsoncc:
The test suite requiring the importer be in a defined location was always the case
...
The change in [59085] changed how the tests failed, stalling the entire test suite rather than failing the individual tests.
Right, it's not a huge problem just unexpected/not a good UX when working with the git mirror/GitHub.
For 6.7, let's consider whether we should revert back to failing only the individual tests rather than existing early.
Sounds good!
#87
in reply to:
↑ 83
@
5 months ago
5 months ago
#88
Thinking perhaps the same approach can be used in other cases. For example the PHP tests may run very slow, and some would fail if the internet connection is slow or flaky. Currently there are nearly 25,000 tests. With a slow/flaky connection they may take 15-20 minutes per run (using Docker/wp-env). Seems that can be improved by skipping tests that require internet to run when they are not essential?
@peterwilsoncc commented on PR #7655:
5 months ago
#89
Seems that can be improved by skipping tests that require internet to run when they are not essential?
There must be some tests missing the http
group that ought to have it as network tests ought to run only when the group is specified. I'll open a ticket.
@peterwilsoncc commented on PR #7655:
5 months ago
#90
Sorry, the group name is external-http
, as noted on the ticket I've created.
@peterwilsoncc commented on PR #7655:
5 months ago
#91
#92
@
5 months ago
- Resolution set to fixed
- Status changed from reopened to closed
Now that the importer test changes have been improved (if I may say so myself), I'll close this off again. Thanks for raising this Ozz!
#93
@
5 months ago
I used the wromng ticket number in the commits:
In r59326:
Tests/Build tools: Only fail importer tests if plugin is missing.
Reverts an earlier change to the test suite in which the PHPUnit tests could not run if the importer plugin was not available.
This update allows the test suite to run and will fail importer tests if the plugin is not available.
Follow up to r59085.
Props peterwilsoncc, azaozz.
Backported to 6.7 in r59327.
Add tests for comment handling.
These tests caught a regression during the 6.6 development cycle (with processing instruction comment tag name) that was fixed, but the tests were not merged.
Trac ticket: https://core.trac.wordpress.org/ticket/61530