Skip to content

Refresh install-wp-tests.sh script #322

Closed

Description

@swissspidy

Feature Request

Describe your use case and the problem you are facing

This script hasn't really seen any major updates, because they haven't been necessary, but I think there's still some room for improvements.

Describe the solution you'd like

Some thoughts and ideas:

  • I don't think we still need install the DB drop-in from https://github.com/markoheijnen/wp-mysqli (which just sets WP_USE_EXT_MYSQL to false) anymore.
  • 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

Activity

  1. added
    command:scaffold-plugin-tests
    command:scaffold-theme-tests
    on Jul 13, 2023
  2. swissspidy commented on Oct 3, 2023

    @swissspidy
    MemberAuthor

    Another thing that's annoying:

    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.

    See swissspidy/performant-translations@108e443

  3. swissspidy commented on Dec 20, 2024

    @swissspidy
    MemberAuthor

    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.

  4. GaryJones commented on Dec 30, 2024

    @GaryJones
    Contributor

    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.

  5. swissspidy commented on Dec 30, 2024

    @swissspidy
    MemberAuthor

    wp-env is an unnecessary abstraction and requires Docker. Not something we should add to this script.

  6. davidperezgar commented on Aug 12, 2025

    @davidperezgar

    I’d also add support for WooCommerce by preinstalling the plugin and making the necessary adjustments in other files.

  7. GaryJones commented on Oct 6, 2025

    @GaryJones
    Contributor

    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.

  8. swissspidy commented on Oct 6, 2025

    @swissspidy
    MemberAuthor

    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.

    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

  9. swissspidy commented on Oct 8, 2025

    @swissspidy
    MemberAuthor
    • 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? 💡

  10. GaryJones commented on Oct 8, 2025

    @GaryJones
    Contributor

    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.

  11. Debarghya-Banerjee commented on Jan 29, 2026

    @Debarghya-Banerjee

    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:

    ~/Library/Application Support/Local/...

    and this include spaces.

    Example DB_HOST value:

    localhost:/Users/.../Application Support/Local/.../mysqld.sock

    When Bash performs word splitting, the value is parsed as:

    PARTS[0]="localhost"
    PARTS[1]="/Users/.../Application"
    PARTS[2]="Support/Local/.../mysqld.sock"

    These lines

    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:

    ln -s
    "/Users/.../Application Support/Local/run/.../mysqld.sock"
    /tmp/localwp-mysql.sock

    Cc: @GaryJones , @swissspidy

  12. GaryJones commented on Feb 5, 2026

    @GaryJones
    Contributor

    Mac OSX already includes an alias - you can use /Users/.../ApplicationSupport/Local/run/.../mysqld.sock (without the troublesome space) and it will automatically work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    command:scaffold-plugin-testscommand:scaffold-theme-tests

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions