Mercurial > hg > hg-git
comparison tests/test-clone.t @ 579:675f19af79ca
tests: extract git command-line client and dulwich requirements into testutil
One or both of these requirements were in almost every test in exactly the same
way. Now, these checks are performed in every test that uses the testutil.
This makes it easier for test authors to add these checks into new tests (just
add a reference to the testutil, which you'd probably want anyway).
We considered having each test declare their requirements (currently, either
"git" or "dulwich"), but in this case, preferred the simplicity of having the
check always performed (even if a particular test doesn't need one or the
other). You can't perform any meaningful testing of Hg-Git without both of
these dependencies properly configured. The main value to checking for them
in the tests (rather than just letting the tests fail) is that it gives a
meaningful error message to help people figure out how to fix their environment.
In the case that either git or dulwich is missing, the information will be
just as clearly conveyed regardless of whether its all the tests that are
skipped, or just most of them.
I didn't add dulwich to hghave (even though this is clearly the sort of thing
that hghave is intended for) because hghave is currently pulled from Mercurial
completely unchanged, and it's probably best to keep it that way.
Tested by running the tests in three configurations:
* No dulwich installed (ran 0, skipped 28, failed 0, output:
Skipped *: missing feature: dulwich)
* Bad git on path (ran 1, skipped 27, failed 0, output:
Skipped *: missing feature: git command line client)
* Working git and correct version of dulwich installed
(ran 28, skipped 0, failed 0)
Thanks to Felipe Contreras for the idea to extract this logic into a library.
author | David M. Carr <david@carrclan.us> |
---|---|
date | Sat, 03 Nov 2012 19:11:50 -0400 |
parents | 935c4fb1bbfc |
children | 6cc99298b69e |
comparison
equal
deleted
inserted
replaced
578:935c4fb1bbfc | 579:675f19af79ca |
---|---|
1 Load commonly used test logic | 1 Load commonly used test logic |
2 $ . "$TESTDIR/testutil" | 2 $ . "$TESTDIR/testutil" |
3 | |
4 bail if the user does not have git command-line client | |
5 $ "$TESTDIR/hghave" git || exit 80 | |
6 | |
7 bail if the user does not have dulwich | |
8 $ python -c 'import dulwich, dulwich.repo' || exit 80 | |
9 | 3 |
10 $ git init gitrepo | 4 $ git init gitrepo |
11 Initialized empty Git repository in $TESTTMP/gitrepo/.git/ | 5 Initialized empty Git repository in $TESTTMP/gitrepo/.git/ |
12 $ cd gitrepo | 6 $ cd gitrepo |
13 $ echo alpha > alpha | 7 $ echo alpha > alpha |