Can't run unit tests in Local sheel

Issue Summary

I’ve tried setting up unit tests with WP-CLI in the Local shell, however I’ve hit a roadblock. I can’t connect to the database because of the socket file path.

Troubleshooting Questions

This happens in all sites on local.

Replication

  1. Open site in Local shell.
  2. Try to run bash bin/install-wp-tests.sh wordpress_test root root localhost:/Users/SebKay/Library/Application Support/Local/run/u5SMXQmdv/mysql/mysqld.sock latest (but change it to the correct path for you setup).
  3. Get the following error error: 'Can't connect to local MySQL server through socket '/Users/SebKay/Library/Application' (2)'

As you can see, it’s cutting off the path after /Users/SebKay/Library/Application, but it should actually be /Users/SebKay/Library/Application Support/Local/run/u5SMXQmdv/mysql/mysqld.sock.

I’ve tried all manner of things, like the classic backslash /Application\ Support, but nothing is working.

Any ideas?

System Details

  • Which version of Local is being used?

    • 5.9.0+4961
  • What Operating System (OS) and OS version is being used?

    • macOS Catalina.

You need to wrap the path in double quotes not single quotes. There’s a space in the path name.

I’ve already tried that but am getting the same result.

All I can assume is that the WP-CLI is sanitising what I enter whether it’s in double quotes, single quotes or the space is backspaced.

Any other ideas?

1 Like

@sebatFHOKE did you ever figure this out? I’m having the same issue at the moment.

Yeah, there’s definitely a lot of room for improvement with getting PHPUnit tests working seamlessly with Local and there might need to be an improvement submitted upstream to the wp scaffold command.

Either way, @afragen was on the right idea with the quoting being the issue.

I was able to get this working by editing the bin/install-wp-tests.sh and replacing the $EXTRA bash variable with the actual socket path, so something like:

	mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS" --socket='/Users/benjamin/Library/Application Support/Local/run/OobiswJRC/mysql/mysqld.sock'

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.