Mercurial > hg > hg-git
view tests/test-convergedmerge.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 |
line wrap: on
line source
Load commonly used test logic $ . "$TESTDIR/testutil" $ hg init hgrepo1 $ cd hgrepo1 $ echo A > afile $ hg add afile $ hg ci -m "origin" $ echo B > afile $ hg ci -m "A->B" $ echo C > afile $ hg ci -m "B->C" $ hg up -r0 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ echo C > afile $ hg ci -m "A->C" created new head $ hg merge -r2 1 files updated, 0 files merged, 0 files removed, 0 files unresolved (branch merge, don't forget to commit) $ hg ci -m "merge" $ hg log --graph --style compact | sed 's/\[.*\]//g' @ 4:3,2 eaa21d002113 1970-01-01 00:00 +0000 test |\ merge | | | o 3:0 ea82b67264a1 1970-01-01 00:00 +0000 test | | A->C | | o | 2 0dbe4ac1a758 1970-01-01 00:00 +0000 test | | B->C | | o | 1 7205e83b5a3f 1970-01-01 00:00 +0000 test |/ A->B | o 0 5d1a6b64f9d0 1970-01-01 00:00 +0000 test origin $ cd .. $ git init --bare gitrepo Initialized empty Git repository in $TESTTMP/gitrepo/ $ cd hgrepo1 $ hg bookmark -r4 master $ hg push -r master ../gitrepo pushing to ../gitrepo searching for changes $ cd .. $ hg clone gitrepo hgrepo2 | grep -v '^updating' importing git objects into hg 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ cd hgrepo2 $ echo % expect the same revision ids as above % expect the same revision ids as above $ hg log --graph --style compact | sed 's/\[.*\]//g' @ 4:1,3 eaa21d002113 1970-01-01 00:00 +0000 test |\ merge | | | o 3 0dbe4ac1a758 1970-01-01 00:00 +0000 test | | B->C | | | o 2:0 7205e83b5a3f 1970-01-01 00:00 +0000 test | | A->B | | o | 1 ea82b67264a1 1970-01-01 00:00 +0000 test |/ A->C | o 0 5d1a6b64f9d0 1970-01-01 00:00 +0000 test origin $ cd ..