Make WordPress Core

02/26/2021 02:07:53 PM (3 years ago)

Build/Test Tools: Switch back to running the PHPUnit test suite against the src directory instead of build.

Some PHPUnit tests were concerned with the state of files in the build directory. In order to allow the tests to run without requiring a build to be run first, these have been moved into assertions that run after the build step (and therefore cause it to fail if they do not pass), or into QUnit tests as necessary.

Various other PHPUnit tests implictly depend on built JavaScript files being present. These files are now touched during the test setup to avoid PHP warnings if the build files are not present.

The wp-tests-config-sample.php file and the GitHub Actions configuration have also been changed so ABSPATH uses src instead of build, therefore allowing the PHPUnit tests to be run without a build having to be run first. This means all new local installations of WordPress will use src for PHPUnit testing. If you would like to switch your existing installation over then change the location of ABSPATH in wp-tests-config.php to point to src instead of build.

Props peterwilsoncc, iandunn, gziolo, desroj, johnbillion

Fixes #51734
See #45863

1 edited


  • trunk/tests/phpunit/includes/abstract-testcase.php

    r49916 r50441  
    12941294        );
    12951295    }
     1297    /**
     1298     * Touches the given file and its directory if it doesn't already exist.
     1299     *
     1300     * This can be used to ensure a file that is implictly relied on in a test exists
     1301     * without it having to be built.
     1302     *
     1303     * @param string $file The file name.
     1304     */
     1305    public static function touch( $file ) {
     1306        if ( file_exists( $file ) ) {
     1307            return;
     1308        }
     1310        $dir = dirname( $file );
     1312        if ( ! file_exists( $dir ) ) {
     1313            mkdir( $dir, 0777, true );
     1314        }
     1316        touch( $file );
     1317    }
Note: See TracChangeset for help on using the changeset viewer.