You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is no good way to keep install-wp-tests.sh in sync with the version here. Developers miss out on important updates.
Even just adding a link to this repo at the top of the file, maybe with a "Last updated" date, would be helpful
Sometimes I had to add a User-Agent header to cURL requests as WordPress.org seemed to block requests otherwise.
e.g. curl -H "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_1) AppleWebKit/537.36 (K HTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36" -s "$1" > "$2";
The script could have built-in MariaDB support, e.g. checking for mariadb-admin
On macOS the files in the tmo wordpress and wordpress-tests-lib can get wiped sometimes, but the folders are still there. But because the script only checks if the folders exist and not the files, it won't recreate the setup.
To make that more robust, we can check if files like "$WP_TESTS_DIR"/includes/functions.php and "$WP_CORE_DIR"/wp-includs.php exist.
GitHub Actions is upgrading to Ubuntu 24 and no longer installs SVN by default. See actions/runner-images#10636
Similarly, in the past Apple has removed Subversion from macOS (starting with 10.15 Catalina)
That means now many people will need to update their GitHub Actions workflows to install Subversion, or have to first install it on their computers.
Luckily WordPress source code can also be downloaded with Git, which is the preferred method for almost everyone. You only really need SVN if you need to commit to core). Thus, I suggest changing the script to use Git.
I came here to report the SVN -> Git thing, so I'm pleased to see it's already on someone else's radar.
I've also considered whether the integration testing of core or plugins could switch to npm—g install @wordpress/env and eliminate the need for the install-wp-tests.sh file. That may make CI and local testing more aligned.
wp-env is an unnecessary abstraction and requires Docker.
@swissspidy Can you please expand on this? Why is it an unnecessary abstraction? The bin/install-wp-tests.sh ultimately/typically requires some other local env to be used, right?
Beyond that educational question, has any work been started on refreshing the script, in a branch somewhere, that could be tested? I've got about 23 plugins that need the CI updating (to install SVN), so switching to a refreshed install script would be as much work.
No one has tackled this yet. There is #346 though. I just pushed #356, which is based on some changes I've used in other projects, followed by some untested changes addressing the items posted here (props Gemini CLI). PTAL.
As for wp-env, my main pain point is that it's using Docker, which hinders adoption and adds performance overhead. It's very opinionated and doesn't support things like object cache. You also can't run it with upcoming PHP versions ahead of time because there are no Docker images available yet.
This simple shell script on the other hand is super easy to set up with whatever PHP/MySQL combination already available on the system.
If someone wants to use wp-env for local development and unit testing, that's up to them, but personally I don't see us adding this to WP-CLI.
I’d also add support for WooCommerce by preinstalling the plugin and making the necessary adjustments in other files.
There is no good way to keep install-wp-tests.sh in sync with the version here. Developers miss out on important updates.
Even just adding a link to this repo at the top of the file, maybe with a "Last updated" date, would be helpful
What if we move the script to a custom WP-CLI command instead? 💡
Often my use case is that I only want the (freshest version of the) install-wp-tests.sh script, and not the rest of the files that get generated with the scaffold plugin tests command. So if that can be separated out to either generate a new file, or update an existing one (with suitable warnings about it being overwritten), then that would be useful.
DB_HOST parsing breaks when socket paths contain spaces
The script parses DB_HOST using the following line:
local PARTS=(${DB_HOST//\:/ })
This line performs two operations:
Parameter expansion
${DB_HOST//:/ } replaces every : character in DB_HOST with a space.
Word splitting during array assignment
The result is assigned to an array using PARTS=( … ), which causes Bash to split the string on whitespace.
On macOS, when using Local by Flywheel, MySQL connections are commonly made via a UNIX socket rather than TCP.
The socket path provided by Local typically lives under:
local DB_HOSTNAME=${PARTS[0]};local DB_SOCK_OR_PORT=${PARTS[1]};
assumes the array contains exactly two elements: host and port/socket.
As a result, the socket path is truncated, and subsequent MySQL commands attempt to connect using an invalid socket path, leading to connection failures.
Verified Workarounds
Using a space-free symlink to the socket works reliably:
Mac OSX already includes an alias - you can use /Users/.../ApplicationSupport/Local/run/.../mysqld.sock (without the troublesome space) and it will automatically work.
Activity
swissspidy commentedon Oct 3, 2023
Another thing that's annoying:
On macOS the files in the tmo
wordpressandwordpress-tests-libcan get wiped sometimes, but the folders are still there. But because the script only checks if the folders exist and not the files, it won't recreate the setup.To make that more robust, we can check if files like
"$WP_TESTS_DIR"/includes/functions.phpand"$WP_CORE_DIR"/wp-includs.phpexist.See swissspidy/performant-translations@108e443
swissspidy commentedon Dec 20, 2024
GitHub Actions is upgrading to Ubuntu 24 and no longer installs SVN by default. See actions/runner-images#10636
Similarly, in the past Apple has removed Subversion from macOS (starting with 10.15 Catalina)
That means now many people will need to update their GitHub Actions workflows to install Subversion, or have to first install it on their computers.
Luckily WordPress source code can also be downloaded with Git, which is the preferred method for almost everyone. You only really need SVN if you need to commit to core). Thus, I suggest changing the script to use Git.
GaryJones commentedon Dec 30, 2024
I came here to report the SVN -> Git thing, so I'm pleased to see it's already on someone else's radar.
I've also considered whether the integration testing of core or plugins could switch to
npm—g install @wordpress/envand eliminate the need for theinstall-wp-tests.shfile. That may make CI and local testing more aligned.swissspidy commentedon Dec 30, 2024
wp-env is an unnecessary abstraction and requires Docker. Not something we should add to this script.
davidperezgar commentedon Aug 12, 2025
I’d also add support for WooCommerce by preinstalling the plugin and making the necessary adjustments in other files.
GaryJones commentedon Oct 6, 2025
@swissspidy Can you please expand on this? Why is it an unnecessary abstraction? The
bin/install-wp-tests.shultimately/typically requires some other local env to be used, right?Beyond that educational question, has any work been started on refreshing the script, in a branch somewhere, that could be tested? I've got about 23 plugins that need the CI updating (to install SVN), so switching to a refreshed install script would be as much work.
swissspidy commentedon Oct 6, 2025
No one has tackled this yet. There is #346 though. I just pushed #356, which is based on some changes I've used in other projects, followed by some untested changes addressing the items posted here (props Gemini CLI). PTAL.
As for wp-env, my main pain point is that it's using Docker, which hinders adoption and adds performance overhead. It's very opinionated and doesn't support things like object cache. You also can't run it with upcoming PHP versions ahead of time because there are no Docker images available yet.
This simple shell script on the other hand is super easy to set up with whatever PHP/MySQL combination already available on the system.
If someone wants to use wp-env for local development and unit testing, that's up to them, but personally I don't see us adding this to WP-CLI.
Yeah plugin dependencies currently require some work, especially when that plugin comes with its own test utils as well. Here's some inspiration involving GlotPress: https://github.com/wearerequired/traduttore/blob/4989685358ea55c1ce6c35c266e078c67e6d3e43/bin/install-wp-tests.sh
swissspidy commentedon Oct 8, 2025
What if we move the script to a custom WP-CLI command instead? 💡
GaryJones commentedon Oct 8, 2025
Often my use case is that I only want the (freshest version of the)
install-wp-tests.shscript, and not the rest of the files that get generated with the scaffold plugin tests command. So if that can be separated out to either generate a new file, or update an existing one (with suitable warnings about it being overwritten), then that would be useful.Debarghya-Banerjee commentedon Jan 29, 2026
DB_HOSTparsing breaks when socket paths contain spacesThe script parses
DB_HOSTusing the following line:This line performs two operations:
Parameter expansion
${DB_HOST//:/ }replaces every:character inDB_HOSTwith a space.Word splitting during array assignment
PARTS=( … ), which causes Bash to split the string on whitespace.On macOS, when using Local by Flywheel, MySQL connections are commonly made via a UNIX socket rather than TCP.
The socket path provided by Local typically lives under:
~/Library/Application Support/Local/...and this include spaces.
Example
DB_HOSTvalue:When Bash performs word splitting, the value is parsed as:
These lines
assumes the array contains exactly two elements: host and port/socket.
As a result, the socket path is truncated, and subsequent MySQL commands attempt to connect using an invalid socket path, leading to connection failures.
Verified Workarounds
Using a space-free symlink to the socket works reliably:
ln -s "/Users/.../Application Support/Local/run/.../mysqld.sock" /tmp/localwp-mysql.sockCc: @GaryJones , @swissspidy
GaryJones commentedon Feb 5, 2026
Mac OSX already includes an alias - you can use
/Users/.../ApplicationSupport/Local/run/.../mysqld.sock(without the troublesome space) and it will automatically work.