Opened 5 years ago
Closed 4 years ago
#50251 closed task (blessed) (fixed)
Report if populate_network() fails during test installation
Reported by: | TimothyBlynJacobs | Owned by: | jorbin |
---|---|---|---|
Milestone: | 5.5 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Build/Test Tools | Keywords: | has-patch has-unit-tests |
Focuses: | Cc: |
Description
While looking into a Gutenberg phpunit issue we discovered that the root cause of tests failing with <h1>Error establishing a database connection</h1>
was that populate_network()
was failing because of a missing WP_TESTS_EMAIL
.
I think it'd be helpful if we reported to the user if populate_network()
returned a WP_Error
instance
Change History (10)
This ticket was mentioned in PR #309 on WordPress/wordpress-develop by TimothyBJacobs.
5 years ago
#1
- Keywords has-patch has-unit-tests added
This ticket was mentioned in Slack in #core by timothybjacobs. View the logs.
5 years ago
#4
@
5 years ago
- Owner set to jorbin
- Resolution set to fixed
- Status changed from new to closed
In 47904:
#5
@
5 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
[47904] would prevent the tests from running when WP_TESTS_DOMAIN
or WP_TESTS_EMAIL
are not defined, however this points to bigger/other problems. WP_TESTS_DOMAIN
and WP_TESTS_EMAIL
are defined in https://core.trac.wordpress.org/browser/tags/5.4.1/wp-tests-config-sample.php#L68 and should always be present.
As far as I see the actual problem here is that wp-tests-config.php
is not present (loaded), or that not all of the constants (settings) there are replaced when that file is not used. Perhaps it would be better to validate that all needed constants are present while doing the bootstrap instead of attempting to run and failing.
This gets a bit trickier as phpunit/includes/install.php
is run in another PHP process from cli, see https://core.trac.wordpress.org/browser/tags/5.4.1/tests/phpunit/includes/bootstrap.php#L100.
#6
follow-up:
↓ 7
@
5 years ago
that not all of the constants (settings) there are replaced when that file is not used.
Our issue was that not all of the constants were loaded, and tracking this down was incredibly difficult because the eventual error message that gets generated is seemingly unrelated.
Perhaps it would be better to validate that all needed constants are present while doing the bootstrap instead of attempting to run and failing.
I think checking that all the constants are defined as expected would be great. I think the populate_network
check is still valuable as well because the checks there are more intricate than just checking for a non-empty value.
#7
in reply to:
↑ 6
@
5 years ago
Replying to TimothyBlynJacobs:
I think the
populate_network
check is still valuable as well
Yes, definitely. Just thinking it would be good to get to the "absolute bottom" of this and fix it once and for all :)
Trac ticket: https://core.trac.wordpress.org/ticket/50251