Make WordPress Core

Changeset 51669


Ignore:
Timestamp:
08/26/2021 05:55:02 PM (3 years ago)
Author:
hellofromTonya
Message:

Tests: Improve bootstrap error message for when ABSPATH folder does not exist.

The PHPUnit tests are/should generally be run on the src directory, so changes just made can be tested. While testing via the build directory is also still supported, this is not the default.

This was last changed in [50441], but that commit did not remove/update the error message thrown by the test bootstrap file.

This last change also did not take into account that that change meant that people had to update their own wptests-config.php` file to match the change made in Core and would otherwise still get the outdated error message.

This commit changes the messaging in the test bootstrap file to be more in line with the current reality, while still accounting for the fact that tests can be run from both src as well as build.

Follow-up to [49569], [50441], [51581].
Props jrf, hellofromTonya.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/bootstrap.php

    r51598 r51669  
    3232
    3333if ( defined( 'WP_RUN_CORE_TESTS' ) && WP_RUN_CORE_TESTS && ! is_dir( ABSPATH ) ) {
    34     echo 'Error: The /build/ directory is missing! Please run `npm run build` prior to running PHPUnit.' . PHP_EOL;
    35     exit( 1 );
     34    if ( substr( ABSPATH, -7 ) !== '/build/' ) {
     35        printf(
     36            'Error: The ABSPATH constant in the `wp-tests-config.php` file is set to a non-existent path "%s". Please verify.' . PHP_EOL,
     37            ABSPATH
     38        );
     39        exit( 1 );
     40    } else {
     41        echo 'Error: The PHPUnit tests should be run on the /src/ directory, not the /build/ directory.'
     42            . ' Please update the ABSPATH constant in your `wp-tests-config.php` file to `dirname( __FILE__ ) . \'/src/\'`'
     43            . ' or run `npm run build` prior to running PHPUnit.' . PHP_EOL;
     44        exit( 1 );
     45    }
    3646}
    3747
Note: See TracChangeset for help on using the changeset viewer.