Functional Tests - a precommit hook
There is a simple script with in the repository's '.hooks' directory which will run nose against the functional tests and will throw an error if you try to commit the repository in a broken state.
If you are doing TDD, the script does give an option to ignore the pre-commit check if it fails so you can commit anyway.
Adding the Hook
Add the following to ".hg/hgrc" in your copy of the repository
[hooks] precommit.RunFunctionalTests = .hooks/precommit.sh
Just as an FYI, this code will also work with a Git repository - link the script to the following target:
In .hooks/precommit.sh (should already be in the repo if you clone it):
nosetests tests/functional code=$? if [ "$code" == "0" ]; then exit 0 fi echo -n "Not all tests pass. Commit (y/n): " read response if [ "$response" == "y" ]; then exit 0 fi exit $code