-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
WP Env PHP Unit debugging #47077
base: trunk
Are you sure you want to change the base?
WP Env PHP Unit debugging #47077
Conversation
Size Change: +1.88 kB (0%) Total Size: 1.33 MB
ℹ️ View Unchanged
|
Flaky tests detected in 7b4623e. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/3975867423
|
RUN if [ -z "$(pecl list | grep xdebug)" ] ; then pecl install xdebug ; fi | ||
RUN docker-php-ext-enable xdebug | ||
RUN echo 'xdebug.start_with_request=yes' >> /usr/local/etc/php/php.ini | ||
RUN echo 'xdebug.mode=${ enableXdebug }' >> /usr/local/etc/php/php.ini | ||
RUN echo '${ clientDetectSettings }' >> /usr/local/etc/php/php.ini | ||
RUN HOST_IP=$(ip route | awk '/default/ { print $3 }'); echo "xdebug.client_host=\"$HOST_IP\"" >> /usr/local/etc/php/php.ini |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this change do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When PHPUnit is used, xdebug is not able to detect host ip within the docker container. It can do it through the browser because of some HTTP fields, but that doesn't exist in the CLI. The host IP is the "default gateway" within the docker container, which can be seen using the ip route
command. This extracts the default gateway from the ip route
command and sets it as host ip.
@@ -237,8 +234,8 @@ module.exports = function buildDockerComposeConfig( config ) { | |||
volumes: developmentMounts, | |||
}, | |||
'tests-wordpress': { | |||
build: '.', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this break how testsPhpVersion
sets the PHP version for the tests-wordpress
environment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does. Well spotted. I changed the code now so that if testsPhpVersion is set, xdebug will not work. I don't have the time to add compatibility for that, but at least if someone does specify this in their config, they will get that php version in tests.
What?
While working on #46952 I found it would be useful to be able to run xdebug in PHP unit tests. This PR makes it possible.