Skip to content

Instantly share code, notes, and snippets.

@dlrobertson
Last active May 15, 2016 20:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dlrobertson/2c494d1f97468468127414dffc318268 to your computer and use it in GitHub Desktop.
Save dlrobertson/2c494d1f97468468127414dffc318268 to your computer and use it in GitHub Desktop.
Documentation for the creation of a `test-tidy` hook

All commits to servo must pass a source code tidiness check. The check may be run with ./mach test-tidy. As a result, it is a good idea to run this check locally before submitting or updating a pull request.

It may be helpful to create a pre-commit or pre-push Git Hook to do the heavy lifting for you. You could add somthing like the following to .git/hooks/pre-commit or .git/hooks/pre-push and make it executable to acheive this.

#!/bin/sh
./mach test-tidy --faster
if [[ $? != 0 ]]; then
    echo >&2 "./mach test-tidy failed: please fix the errors above"
    exit 1
fi

If you're using a unix shell, something like the following should work.

$ cat > .git/hooks/pre-commit << EOF
#!/bin/sh
./mach test-tidy --faster
if [[ \$? != 0 ]]; then
    echo >&2 "./mach test-tidy failed: please fix the errors above"
    exit 1
fi
EOF
$ chmod 755 .git/hooks/pre-commit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment