Opened 4 months ago
Last modified 19 hours ago
#61530 new task (blessed)
Test tool and unit test improvements for 6.7
Reported by: | jonsurrell | Owned by: | |
---|---|---|---|
Milestone: | 6.7 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Build/Test Tools | Keywords: | has-patch has-unit-tests |
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 (67)
This ticket was mentioned in Slack in #core by jonsurrell. View the logs.
4 months ago
This ticket was mentioned in PR #6765 on WordPress/wordpress-develop by @jonsurrell.
4 months ago
#2
- Keywords has-patch has-unit-tests added
#3
@
4 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:
4 months ago
#4
Good suggestions, thanks @aaronjorbin. I've applied them.
This ticket was mentioned in PR #6765 on WordPress/wordpress-develop by @jonsurrell.
3 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.
3 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:
3 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.
3 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.
3 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.
3 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.
3 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
@
3 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
@
3 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:
3 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.
3 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
@
3 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.
3 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:
3 months ago
#25
This ticket was mentioned in PR #7362 on WordPress/wordpress-develop by @jrf.
3 weeks 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
@
3 weeks 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.
3 weeks 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
@
3 weeks 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.
3 weeks 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
@
3 weeks 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.
3 weeks ago
#39
Trac ticket: https://core.trac.wordpress.org/ticket/61530
#40
@
3 weeks ago
I've opened GH PR #7365 with another two fixes to resolve test failures on Windows.
@hellofromTonya commented on PR #7365:
3 weeks ago
#42
Committed via https://core.trac.wordpress.org/changeset/59054 ✅
#43
@
3 weeks 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:
3 weeks 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:
3 weeks ago
#47
Thanks for the PR! Merged in r59082.
@SergeyBiryukov commented on PR #7363:
2 weeks ago
#50
Thanks for the PR! Merged in r59085.
#51
@
2 weeks 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
@
2 weeks 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 ?
2 weeks ago
#53
Thanks @SergeyBiryukov! And thanks for adding the WP_RUN_CORE_TESTS
check to the condition too.
#54
@
2 weeks 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
@
2 weeks 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
@
2 weeks 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
@
2 weeks 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
@
2 weeks 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
@
2 weeks 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.
9 days 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:
5 days ago
#65
This ticket was mentioned in PR #7535 on WordPress/wordpress-develop by @peterwilsoncc.
3 days ago
#66
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.
Trac ticket: https://core.trac.wordpress.org/ticket/61530