Make WordPress Core


Ignore:
Timestamp:
08/07/2021 02:45:08 PM (5 years ago)
Author:
SergeyBiryukov
Message:

Build/Test Tools: Fix message display in test bootstrap.

Any messages to the user which are echo-ed out in the test bootstrap will generally display on a command-line interface.

The *nix specific "\n" line ending will be ignored on Windows, making the messages less readable.

For new lines in CLI messages, PHP_EOL should be used instead.

This was already done in a few places in the script, but not consistently so. Fixed now.

Follow-up to [UT882], [UT890], [44723], [45020], [48592], [49535], [51560].

Props jrf.
See #53363.

File:
1 edited

Legend:

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

    r51575 r51581  
    2424
    2525if ( ! is_readable( $config_file_path ) ) {
    26         echo "Error: wp-tests-config.php is missing! Please use wp-tests-config-sample.php to create a config file.\n";
     26        echo 'Error: wp-tests-config.php is missing! Please use wp-tests-config-sample.php to create a config file.' . PHP_EOL;
    2727        exit( 1 );
    2828}
     
    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.\n";
     34        echo 'Error: The /build/ directory is missing! Please run `npm run build` prior to running PHPUnit.' . PHP_EOL;
    3535        exit( 1 );
    3636}
     
    4040if ( version_compare( $phpunit_version, '5.7.21', '<' ) ) {
    4141        printf(
    42                 "Error: Looks like you're using PHPUnit %s. WordPress requires at least PHPUnit 5.7.21.\n",
     42                'Error: Looks like you’re using PHPUnit %s. WordPress requires at least PHPUnit 5.7.21.' . PHP_EOL,
    4343                $phpunit_version
    4444        );
    45         echo "Please use the latest PHPUnit version supported for the PHP version you are running the tests on.\n";
     45        echo 'Please use the latest PHPUnit version supported for the PHP version you are running the tests on.' . PHP_EOL;
    4646        exit( 1 );
    4747}
     
    5050$phpunit_polyfills_autoloader = __DIR__ . '/../../../vendor/yoast/phpunit-polyfills/phpunitpolyfills-autoload.php';
    5151if ( ! file_exists( $phpunit_polyfills_autoloader ) ) {
    52         echo "Error: You need to run `composer update` before running the tests.\n";
    53         echo "You can still use a PHPUnit phar to run them, but the dependencies do need to be installed.\n";
     52        echo 'Error: You need to run `composer update` before running the tests.' . PHP_EOL;
     53        echo 'You can still use a PHPUnit phar to run them, but the dependencies do need to be installed.' . PHP_EOL;
    5454        exit( 1 );
    5555}
     
    7070        if ( $missing_extensions ) {
    7171                printf(
    72                         "Error: The following required PHP extensions are missing from the testing environment: %s.\n",
     72                        'Error: The following required PHP extensions are missing from the testing environment: %s.' . PHP_EOL,
    7373                        implode( ', ', $missing_extensions )
    7474                );
    75                 echo "Please make sure they are installed and enabled.\n",
     75                echo 'Please make sure they are installed and enabled.' . PHP_EOL,
    7676                exit( 1 );
    7777        }
     
    9494if ( $missing_constants ) {
    9595        printf(
    96                 "Error: The following required constants are not defined: %s.\n",
     96                'Error: The following required constants are not defined: %s.' . PHP_EOL,
    9797                implode( ', ', $missing_constants )
    9898        );
    99         echo "Please check out `wp-tests-config-sample.php` for an example.\n",
     99        echo 'Please check out `wp-tests-config-sample.php` for an example.' . PHP_EOL,
    100100        exit( 1 );
    101101}
Note: See TracChangeset for help on using the changeset viewer.