From d69f192dad806a3c1e15fa8b8218d1851f60bd37 Mon Sep 17 00:00:00 2001
From: jrfnl <jrfnl@users.noreply.github.com>
Date: Sat, 7 Aug 2021 00:57:13 +0200
Subject: [PATCH] Build/Tests: 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.
---
tests/phpunit/includes/bootstrap.php | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/tests/phpunit/includes/bootstrap.php b/tests/phpunit/includes/bootstrap.php
index 0af29cc287..99f2f88eca 100644
a
|
b
|
if ( defined( 'WP_TESTS_CONFIG_FILE_PATH' ) ) { |
23 | 23 | global $wpdb, $current_site, $current_blog, $wp_rewrite, $shortcode_tags, $wp, $phpmailer, $wp_theme_directories; |
24 | 24 | |
25 | 25 | if ( ! 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; |
27 | 27 | exit( 1 ); |
28 | 28 | } |
29 | 29 | |
… |
… |
require_once $config_file_path; |
31 | 31 | require_once __DIR__ . '/functions.php'; |
32 | 32 | |
33 | 33 | if ( 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; |
35 | 35 | exit( 1 ); |
36 | 36 | } |
37 | 37 | |
… |
… |
$phpunit_version = tests_get_phpunit_version(); |
39 | 39 | |
40 | 40 | if ( version_compare( $phpunit_version, '5.7.21', '<' ) ) { |
41 | 41 | 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.', |
43 | 43 | $phpunit_version |
44 | | ); |
45 | | echo "Please use the latest PHPUnit version supported for the PHP version you are running the tests on.\n"; |
| 44 | ) . PHP_EOL; |
| 45 | echo 'Please use the latest PHPUnit version supported for the PHP version you are running the tests on.', PHP_EOL; |
46 | 46 | exit( 1 ); |
47 | 47 | } |
48 | 48 | |
49 | 49 | // Check that the PHPUnit Polyfills autoloader exists. |
50 | 50 | $phpunit_polyfills_autoloader = __DIR__ . '/../../../vendor/yoast/phpunit-polyfills/phpunitpolyfills-autoload.php'; |
51 | 51 | if ( ! 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; |
54 | 54 | exit( 1 ); |
55 | 55 | } |
56 | 56 | |
… |
… |
if ( defined( 'WP_RUN_CORE_TESTS' ) && WP_RUN_CORE_TESTS ) { |
69 | 69 | |
70 | 70 | if ( $missing_extensions ) { |
71 | 71 | 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.', |
73 | 73 | implode( ', ', $missing_extensions ) |
74 | | ); |
75 | | echo "Please make sure they are installed and enabled.\n", |
| 74 | ) . PHP_EOL; |
| 75 | echo 'Please make sure they are installed and enabled.', PHP_EOL, |
76 | 76 | exit( 1 ); |
77 | 77 | } |
78 | 78 | } |
… |
… |
foreach ( $required_constants as $constant ) { |
93 | 93 | |
94 | 94 | if ( $missing_constants ) { |
95 | 95 | printf( |
96 | | "Error: The following required constants are not defined: %s.\n", |
| 96 | 'Error: The following required constants are not defined: %s.', |
97 | 97 | implode( ', ', $missing_constants ) |
98 | | ); |
99 | | echo "Please check out `wp-tests-config-sample.php` for an example.\n", |
| 98 | ) . PHP_EOL; |
| 99 | echo 'Please check out `wp-tests-config-sample.php` for an example.', PHP_EOL, |
100 | 100 | exit( 1 ); |
101 | 101 | } |
102 | 102 | |