[wp-trac] [WordPress Trac] #57844: Tests/Script Loader: Run build step in PHP Unit test actions.

WordPress Trac noreply at wordpress.org
Fri Mar 3 10:03:53 UTC 2023


#57844: Tests/Script Loader: Run build step in PHP Unit test actions.
------------------------------+---------------------
 Reporter:  peterwilsoncc     |       Owner:  (none)
     Type:  defect (bug)      |      Status:  new
 Priority:  normal            |   Milestone:  6.2
Component:  Build/Test Tools  |     Version:
 Severity:  normal            |  Resolution:
 Keywords:  has-patch close   |     Focuses:
------------------------------+---------------------

Comment (by SergeyBiryukov):

 Replying to [comment:10 azaozz]:
 > 2. Automated testing should always be done on the production files, i.e.
 in /build and without SCRIPT_DEBUG and probably without WP_DEBUG. If
 testing of the non-production files is needed, it can be done in another
 run of the test tools. Testing non-production files (in /src and/or with
 SCRIPT_DEBUG, etc.) is just wrong as it may miss several kinds of bugs and
 errors, sometimes severe (has happened in the past).

 Hmm, #51734 had some good arguments for running PHPUnit tests from `src`
 instead of `build`:

 > 1. Running a build is slow. It copies all the files and builds,
 validates, and minifies all the CSS and JS. None of this should be
 necessary for PHP testing.
 > 2. A developer iterating on a patch in the source file has no way of
 knowing that their file is not actually being tested when running the
 tests, unless they run the build each time or start and run the file
 watcher. This is an easy step to forget.
 > 3. PHP errors display a stack trace from `build` instead `src`.
 > 4. Breakpoint debugging isn't fun as it also uses the stack trace from
 `build` instead of `src`.
 > 5. Any test which requires a build step is not a unit test and should be
 tested using other means, for example as a validation step during the
 build process.

 As someone who runs PHP tests locally on pretty much a daily basis, I find
 it very helpful that the build step is currently not required for that,
 saves a lot of time :)

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/57844#comment:12>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list