WordPress.org

Make WordPress Core

Opened 13 months ago

Last modified 6 months ago

#40532 new defect (bug)

Find a workaround for unit tests that have a dependency on XDebug

Reported by: johnbillion Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: needs-patch needs-unit-tests
Focuses: Cc:

Description

In #39978, XDebug was disabled when running the test suite on Travis. This resulted in a 40% increase in build speed and a 40% decrease in developer frustration.

Unfortunately it was overlooked that two tests in core have a dependency on XDebug:

  • Tests_Ajax_Response::test_response_charset_in_header() (ref)
  • Tests_oEmbed_HTTP_Headers::test_rest_pre_serve_request_headers() (ref)

Both of these tests are skipped when XDebug isn't available, so they're no longer tested on Travis.

A workaround needs to be found for these tests so they no longer rely on XDebug.

Change History (3)

#1 @jmichaelward
6 months ago

I spent some time digging around the web for answers to this issue and have come up mostly empty. One question I do have is whether the speed in which tests run in Travis are related to the mere presence of Xdebug, or rather that Xdebug is enabled for the duration of the test process.

Xdebug does have two methods - xdebug_enable and xdebug_disable which, I would think, could be triggered within particular tests that require the xdebug_get_headers method. This would require Xdebug to be included in the Travis PHP ini file, but with the default_enable flag set to false and, I believe, remote_enable set to true. Outside of that, I haven't found a definitive way to get headers while PHP is running in the CLI.

#2 @johnbillion
6 months ago

Thanks for looking into this, @jmichaelward. I believe that the mere presence of Xdebug impacts the performance, but this assumption would benefit from some testing.

#3 @netweb
6 months ago

The other option I'd thought of was to create a new PHPUnit test group, similar to the ajax, ms-files, external-http etc groups specifically for Xdebug, tests that require it are moved into that group and that group only is tested with Xdebug enabled, again, this would need some testing for feasibility.

Note: See TracTickets for help on using tickets.