Automatically run tests upon detecting writes to source(s).
If you're developing on Linux, you've got no reason not to be using this. Just be careful not to set off your cats!
- ASCII text colors to render green/red boxes
- Audio alerts
- Desktoppings, to change desktop background (aka wallpaper)
- Tweakable sounds, colors, pictures via a per-proj or $HOME config file
- Super-fast monitoring via inotify
- Dirt simple hackable script; just wraps nosetests or whatever suite you want
- Run-any-time control; accepts single SIGINT to re-run even if no changes detected
- All-in-one test runner; trivial to use
- Minimal output, with screen clearing
- Basic stats to log your change times and passes/fails (see your patterns/habits)
- It really purrs!
- Example video!
Anti-features:
- Only runs on platforms supporting inotify (which means just linux (AFAICT).
Dependencies (some could be substituted/disabled): gconftool-2 notify-send play pyinotify
Install packages with: apt-get install gconf2 libnotify-bin sox python-pyinotify
Uses pyinotify to address performance issues inherent in busy-wait looping (python-inotifyx might be alternative).
Pass a list of files to be watched. If a source file can be tested by: % nosetests hello.py then it should work with this.
Example:
% autotest.py **/*.py # Auto-test all Python files
Collects whatever files you specify, as opposed to just monitoring a directory/tree. This makes it easier to only test exactly the sources you want to track. See usage example by running it.
Does flamboyant notification through three mechanisms:
- red/green text bar in console where it runs
- pop-up desktop notification
- desktop background color change
You may need to set your desktop background to be a non-image to get desktop coloring to work.
There are Color codes (for color, blinking, bold, underline, etc).
You'll have to use xterm or konsole if you want the lovely blinking errors (Eterm and gnome-terminal don't support) since they're the only ttys I can find that still support it. Kinda useful to have the red fail bar blinking at you. They has a cool (probably accidental) behavior where if you give the window focus and then unfocus it will stop blinking.
Since writing this a couple years ago (and keeping it under a rock), another nice-looking version of the autotest concept has surfaced. I haven't tried it yet, but I expect that this tiny script you're looking at is still a good way to go if you want nice simple output and a means to monitor specific file(s) in a light-weight fashion, using whatever testing mechanism you want.
Some ideas borrowed from Jeff Winkler's nosy, the TIP list, and Django's runserver.
The green/red bars are from Kent Beck's TDD book, but they're common.
Autotest for Ruby has been around for a while. I didn't know about it when I wrote this, but I've since contributed desktoppings to it. I got the "double-interrupt" idea from it, as well as run-at-startup. It has some features to re-run full suites vs single failing files that should be considered as additions here.
Some great notification ideas/extensions (alternative popups and a few sound/image ideas) were borrowed from a Ruby autotest add-on called autotest-notification.
- A testing tool should probably have some tests! But since results are mostly visual probably not worth attempting.
- Move global variables to separate file to be tweakable params (a la mailman), or maybe should just accept CLI options.
- Move all this verbiage into a proper README.
- Convert to proper project and put up as full repo on github.
- Stats tracking.
- Convert to Python3, but pyinotify might not be working with it yet. Just run 2to3 to create patch. Trying to make this support both version is tricky due to printing of colors.
- See what tweaks are needed to get working with rdoctests.