Inside Out

Test driven setup with tmux and entr

This post provides a setup for test driven development with instant feedback. You can use any editor with your favorite test runner for any language. Here’s a screencast of our end goal (opens in a new tab).

Let’s go step by step now. Our setup requires:

Before we start…

We’ll install a few pre-requisites.

$ sudo pacman -S tmux
$ yaourt -S entr

These are installation commands for Arch Linux. Please replace them with your favorite package manager on the box.

Watch for changes

Enter entr. Jokes aside, this tool is one of the most simple and best available for the job at hand. An alternative is the facebook watchman. While it seems awesome as well, the setup (daemon, client etc.) seemed too much for this task.

Our oneliner is here.

$ ls **/*.py | entr -s 'pytest; [[ $? -eq 0 ]] && bg="colour22" || bg="colour124"; tmux set-window-option -g window-status-current-bg $bg'

Breaking it apart…

Please experiment to choose the appropriate colors for your terminal/tmux theme :)

That’s all for today. Hope you enjoy the test driven setup!