Visual and Audible PHPUnit Feedback with Blink(1)
One day, I was running a long test suite and found myself constantly flipping back and forth between my terminal and text editor. I realized I did this all the time and wondered if there was an easy way to be notified when the test suite finished. I found it in a little USB light called blink(1) and it turns out it's really simple to set up.
What's the blink(1)?
blink(1) is a USB notification light which can be programmed to notify you of all sorts of things. Twitter mentions, new GitHub issues, emails, or even package shipping status updates. And for those of you in traditional offices, it can also be used as an Available/Meeting/Busy status light.
Yesterday I posted an image and video demonstrating what happens when I run PHPUnit tests on my iMac. When they pass, the blink(1) connected to my keyboard lights up green. If my tests fail, I get a red light. While the tests are running, the light turns blue. I also use blink(1) to notify me of other random things.
Sweet, what do you need to do this?
It doesn't take much to get this going. All you need is:
- A computer with PHPUnit installed
- A blink(1) mk2 USB light (affiliate link)
- The blink1-tool CLI
- One of these aliases
Setting it all up
Setting it up is also pretty easy:
- Make sure you have
PATH. I personally install PHPUnit globally
- Download the blink1-tool CLI utility and move it into your path. I put mine in
usr/local/bin/with this command:
mv ~/david/Downloads/blink1-tool /usr/local/bin
- Lastly, install one of these aliases into your
aliases.zsh. These aliases create and run a new function called
__phpunit, which checks to see if you have a blink(1) light connected to your computer, and if so turns the light blue, runs
phpunitand conditionally change the light's color based on the exit status. My personal version is also configured to play the sound "GODLIKE" from Unreal Tournament when my tests pass. You can get my sound here
All in all, it's pretty easy to set up if you're comfortable with a little bit of command line and this set up satisfies the little geeky computer nerd part of me. Let me know if you decide to get a similar set up or have any troubles getting this running.