Sometimes I find myself working backwards up a tree of errors to fix a problem. Today was a case in point.

Since I’ve been doing a bit of WordPress grooming, I have the development build checked out locally. Previously I had run phpunit against the unit tests included in the code, but for some reason when I tried to run things under NetBeans, it would error out (Bug 247704).

So today I started playing with things again, only to see an error at the command line about a missing library:

....................................F........FFPHP Fatal error:  Call to undefined function imagecreatefrompng() in /Volumes/Macintosh HD2/Projects/WordPress/tests/phpunit/tests/image/editor_gd.php on line 510

A little bit of Googling and I find that the version of PHP that ships with Yosemite doesn’t include the PNG library. So mystery partially solved – when I upgraded to Yosemite, the version of PHP that I’d loaded with HomeBrew previously was replaced by the one that comes from Apple.

The Stack Overflow post http://stackoverflow.com/questions/26493762/yosemite-php-gd-mcrypt-installation says you can fix this by installing PHP from HomeBrew, which I have installed already (I used it to install node.js).

I had forgotten that I had HomeBrew installed, so I started off with that install, only to get an odd error message:

server:WordPress robweaver$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
It appears Homebrew is already installed. If your intent is to reinstall you
should do the following before running this installer again:
    rm -rf /usr/local/Cellar /usr/local/.git && brew cleanup

OK, so looks like I already have it, but since I’m not sure if it was from before I upgraded OS X to Yosemite, I do a check, only to get an error:

server:WordPress robweaver$ brew doctor
/usr/local/bin/brew: /usr/local/Library/brew.rb: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby: bad interpreter: No such file or directory
/usr/local/bin/brew: line 21: /usr/local/Library/brew.rb: Undefined error: 0

More Googling gets me to a thread on the HomeBrew site talking about an update for Yosemite (https://github.com/Homebrew/homebrew/pull/29796) and a couple of workarounds people have tried. It occurs to me that since the version of Ruby was changed with this update, I could use a trick I’ve used in the past and just add a symlink in Ruby framework folder to get HomeBrew to use the 2.0 Ruby:

server:~ robweaver$ cd /System/Library/Frameworks/Ruby.framework/Versions/
server:Versions robweaver$ ls
2.0 Current
server:Versions robweaver$ sudo ln -s 2.0 1.8
server:Versions robweaver$ ls
1.8 2.0 Current

Now I’m able to run the command to reinstall without the interpreter error, but … apparently the /usr/local folder is not writable.

server:~ robweaver$ \curl -L https://get.rvm.io | bash -s stable --ruby
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   184  100   184    0     0     79      0  0:00:02  0:00:02 --:--:--    79
100 22817  100 22817    0     0   7214      0  0:00:03  0:00:03 --:--:-- 69352
Downloading https://github.com/wayneeseguin/rvm/archive/1.26.9.tar.gz
Downloading https://github.com/wayneeseguin/rvm/releases/download/1.26.9/1.26.9.tar.gz.asc
Found PGP signature at: 'https://github.com/wayneeseguin/rvm/releases/download/1.26.9/1.26.9.tar.gz.asc',
but no GPG software exists to validate it, skipping.

Upgrading the RVM installation in /Users/robweaver/.rvm/
    RVM PATH line found in /Users/robweaver/.mkshrc /Users/robweaver/.profile /Users/robweaver/.bashrc /Users/robweaver/.zshrc.
    RVM sourcing line found in /Users/robweaver/.profile /Users/robweaver/.bash_profile /Users/robweaver/.zlogin.
Upgrade of RVM in /Users/robweaver/.rvm/ is complete.

# Rob Weaver,
#
#   Thank you for using RVM!
#   We sincerely hope that RVM helps to make your life easier and more enjoyable!!!
#
# ~Wayne, Michal & team.

In case of problems: http://rvm.io/help and https://twitter.com/rvm_io

Upgrade Notes:


  * WARNING: You have '~/.profile' file, you might want to load it,
    to do that add the following line to '/Users/robweaver/.bash_profile':

      source ~/.profile

  * No new notes to display.

rvm 1.26.9 (latest) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.10/x86_64/ruby-2.2.0.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
ERROR: '/usr/local/bin' is not writable - it is required for Homebrew, try 'brew doctor' to fix it!
Requirements installation failed with status: 1.

Running ‘brew doctor’ shows me a bit more about this problem:

Warning: The /usr/local directory is not writable.
Even if this directory was writable when you installed Homebrew, other
software may change permissions on this directory. Some versions of the
"InstantOn" component of Airfoil are known to do this.

You should probably change the ownership and permissions of /usr/local
back to your user account.

So I update the permissions of the /usr/local to allow me to write to it only to get some more errors

Error running 'requirements_osx_brew_libs_install autoconf automake libtool pkg-config libyaml readline libksba openssl',
showing last 15 lines of /Users/robweaver/.rvm/log/1421002851_ruby-2.2.0/package_install_autoconf_automake_libtool_pkg-config_libyaml_readline_libksba_openssl.log
++ /scripts/functions/logging : rvm_pretty_print()  81 > case "$1" in
++ /scripts/functions/logging : rvm_pretty_print()  82 > [[ -t 1 ]]
++ /scripts/functions/logging : rvm_pretty_print()  82 > return 1
++ /scripts/functions/logging : rvm_warn()  139 > printf %b 'There were package installation errors, make sure to read the log.

Try `brew tap --repair` and make sure `brew doctor` looks reasonable.

Check Homebrew requirements https://github.com/Homebrew/homebrew/wiki/Installation\n'
There were package installation errors, make sure to read the log.

Try `brew tap --repair` and make sure `brew doctor` looks reasonable.

Check Homebrew requirements https://github.com/Homebrew/homebrew/wiki/Installation
++ /scripts/functions/requirements/osx_brew : requirements_osx_brew_libs_install()  63 > case "$_system_version" in
++ /scripts/functions/requirements/osx_brew : requirements_osx_brew_libs_install()  70 > return 1
Requirements installation failed with status: 1.

So following the steps outlined by brew itself, I clean things up a bit, and finally I’m successful in getting brew to update. Then I install PHP 5.6 using “brew install php56”.

Running the phpunit from the command line again, I get a bunch of errors, but these are all because the unit tests expect an empty database to start with (the failure I was getting before meant the test DB didn’t get cleared out).

So clean out the DB, and now my tests from the command line work (well except for a couple of actual test failures, but no more PNG error):

............................................................. 2989 / 3049 ( 98%)
................................................SSSSSSSSSSSS

Time: 1.34 minutes, Memory: 130.50Mb

There were 3 failures:

1) Tests_Get_Archives::test_wp_get_archives_limit
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'<li><a href='http://example.org/?p=907'>Post title 8</a></li>
-   <li><a href='http://example.org/?p=906'>Post title 7</a></li>
-   <li><a href='http://example.org/?p=905'>Post title 6</a></li>
-   <li><a href='http://example.org/?p=904'>Post title 5</a></li>
-   <li><a href='http://example.org/?p=903'>Post title 4</a></li>'
+'<li><a href='http://example.org/?p=900'>Post title 1</a></li>
+   <li><a href='http://example.org/?p=901'>Post title 2</a></li>
+   <li><a href='http://example.org/?p=902'>Post title 3</a></li>
+   <li><a href='http://example.org/?p=903'>Post title 4</a></li>
+   <li><a href='http://example.org/?p=904'>Post title 5</a></li>'

/Volumes/Macintosh HD2/Projects/WordPress/tests/phpunit/tests/functions/getArchives.php:48

2) Tests_Theme::test_get_themes_contents
Failed asserting that false is true.

/Volumes/Macintosh HD2/Projects/WordPress/tests/phpunit/tests/theme.php:118

3) Tests_Theme::test_switch_theme
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'OmnisRisk/omnistools'
+'OmnisRisk'

/Volumes/Macintosh HD2/Projects/WordPress/tests/phpunit/tests/theme.php:224
                                                         
FAILURES!                                                
Tests: 3049, Assertions: 11314, Failures: 3, Skipped: 44.

Still didn’t completely fix my NetBeans error, but at least now I can unit test WordPress and figure out if there are things I can contribute to that community.

 

 

Hi, I’m Rob Weaver