Automatically test things after commiting.
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Git autotest

Auto test Git repositories after commiting

Makes it so that every time you commit to a Git repo, you'll get a Growl/Libnotify notification telling you if your tests pass or fail.


If you have ShellBundler installed, just drop this on your ~/.bash/bundle.

$ git checkout git:// ~/.bash/bundle

Installation for everyone else

No ShellBundler? Okay. Check me out somewhere then run make install.

$ git checkout git://
$ cd git-autotest
$ make install

...or just add the bin/ to your $PATH. Whatever you like, soldier.


Enable it on a Git repo:

$ git autotest install

If you use something else other than rake test as a test command, instead use:

$ git autotest install "rake spec"    # or whatevs

Now commit something:

$ touch file.txt
$ git commit -a -m "Yo."

You'll get growl/libnotify notifications! Hooray!

How does it work?

This is the simplest autotester yet.

On install

When you install (git autotest install) it, it does:

  • Set the autotest command to what you specify (defaults to rake test). You'll find this in .git/config.
  • Adds a post-commit hook to run the tests (git autotest run). This is in .git/hooks.
  • Ignores test.log in that repository.
  • ...No, none of these changes will be committed to your repository. They will be local settings on your working copy.

On commit

When you commit something in your repository, it invokes the post-commit hook. What that does is:

  • Send a Growl notification "Running tests..."
  • Invoke the autotest command in the background. Output is piped onto test.log.
  • If the test command returns an exit code of 0,
    • Send a Growl notification saying "Tests are okay"
  • If the test command returns an exit code of non-zero,
    • Send a Growl notification saying "Tests failed."

This is a post-commit hook. It's invoked in the background after a commit happens. It will not stop you from committing if tests fail.

What if I want to stop the commit if tests fail?

git-autotest doesn't let you do that. However, that's really really easy and you don't need any tools to do that:

$ echo "rake test" >> .git/hooks/pre-commit


  • in Mac OSX: growlnotify
  • in Ubuntu: libnotify (which already comes installed in the desktop edition)