tests: use Git's test framework

This allows tests to run in parallel as well as letting us use "prove"
or another TAP harness to run the tests.

Git's test framework requires Git to be fully built before letting any
tests run, so add a new target to the top-level Makefile which builds
all of Git instead of just libgit.a and make the "test" target depend on
that.

Signed-off-by: John Keeping <john@keeping.me.uk>
tests: use git's skip_all for missing tidy

Ideally we'd be able to use test_have_prereq and test_set_prereq to test
and set features, but for now, calling `which` directly is sufficient.

Adding skip_all lets git's test harness know why we're bailing early.
tests: use Git test functions directly

This removes the run_test and tests_done wrapper functions, changing
everywhere they were used to use the correct Git test functions instead.

Signed-off-by: John Keeping <john@keeping.me.uk>
tests: don't let Git's test-lib create a repository

We create our own repository structure for all CGit tests, so letting
Git's test-lib.sh create one as well just causes an unnecessary call to
git-init.

Signed-off-by: John Keeping <john@keeping.me.uk>
tests: remove prepare_tests

Instead, setup the test repositories automatically.  Provide a variable
that can be used by tests to override this behaviour if they want.

Signed-off-by: John Keeping <john@keeping.me.uk>
t0001: don't setup test repositories

This test doesn't use the test repositories, so it doesn't need them
created.

Signed-off-by: John Keeping <john@keeping.me.uk>
tests/.gitignore: update for using Git's test infrastructure

Signed-off-by: John Keeping <john@keeping.me.uk>
tests: remove "trash" directory

Now that we're using Git's test framework, it generates a suitable trash
directory for us to use, so we don't need to create a "trash"
subdirectory.

This patch was generated with "sed -i -e 's!trash/!!g' tests/*.sh" with
the t0107-snapshot.sh tests fixed to avoid passing "-C trash" to tar or
"-d trash" to unzip.

Signed-off-by: John Keeping <john@keeping.me.uk>
.gitignore: tighten cgit ignore expression

This will allow wrappers added under tests/ to be added to version
control.

Signed-off-by: John Keeping <john@keeping.me.uk>
tests: put cgit onto $PATH

This will allow us to override the path with wrappers to provide
additional functionality, such as for Valgrind.

Signed-off-by: John Keeping <john@keeping.me.uk>
tests: add Valgrind support

Now running tests with the "--valgrind" option will run cgit under
Valgrind instead of all Git commands.

Signed-off-by: John Keeping <john@keeping.me.uk>
t0001: use test_cmp instead of 'diff -u'

Signed-off-by: John Keeping <john@keeping.me.uk>
tests: use test_line_count where appropriate

This gets us better output when the line count is incorrect, which will
help debugging test failures.

Signed-off-by: John Keeping <john@keeping.me.uk>
tests: use test_create_repo instead of "git init"

This gets us a more consistent initial repository state with a fixed
template and no hooks.

Also change the setup code to use a subshell instead of the "cd there;
...; cd back" anti-pattern.

Signed-off-by: John Keeping <john@keeping.me.uk>
t0010-validate-html: use new git's test completion method