Skip to content

Commit 53f5ead

Browse files
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. git-svn-id: https://develop.svn.wordpress.org/trunk@51581 602fd350-edb4-49c9-b593-d223f7449a82
1 parent fa2c313 commit 53f5ead

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

tests/phpunit/includes/bootstrap.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,34 +23,34 @@
2323
global $wpdb, $current_site, $current_blog, $wp_rewrite, $shortcode_tags, $wp, $phpmailer, $wp_theme_directories;
2424

2525
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;
2727
exit( 1 );
2828
}
2929

3030
require_once $config_file_path;
3131
require_once __DIR__ . '/functions.php';
3232

3333
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;
3535
exit( 1 );
3636
}
3737

3838
$phpunit_version = tests_get_phpunit_version();
3939

4040
if ( 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 youre 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
}
4848

4949
// Check that the PHPUnit Polyfills autoloader exists.
5050
$phpunit_polyfills_autoloader = __DIR__ . '/../../../vendor/yoast/phpunit-polyfills/phpunitpolyfills-autoload.php';
5151
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;
5454
exit( 1 );
5555
}
5656

@@ -69,10 +69,10 @@
6969

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
}
7878
}
@@ -93,10 +93,10 @@
9393

9494
if ( $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
}
102102

0 commit comments

Comments
 (0)