Skip to content

Commit 6201d43

Browse files
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 `wp`tests-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. git-svn-id: https://develop.svn.wordpress.org/trunk@51669 602fd350-edb4-49c9-b593-d223f7449a82
1 parent d616b93 commit 6201d43

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

tests/phpunit/includes/bootstrap.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,18 @@
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.' . 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

3848
$phpunit_version = tests_get_phpunit_version();

0 commit comments

Comments
 (0)