Mercurial > hg > hg-git
view 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 |
line wrap: on
line source
Load commonly used test logic $ . "$TESTDIR/testutil" $ git init gitrepo Initialized empty Git repository in $TESTTMP/gitrepo/.git/ $ cd gitrepo $ echo alpha > alpha $ git add alpha $ fn_git_commit -m 'add alpha' $ git tag alpha $ git checkout -b beta 2>&1 | sed s/\'/\"/g Switched to a new branch "beta" $ echo beta > beta $ git add beta $ fn_git_commit -m 'add beta' $ cd .. $ echo % clone a tag % clone a tag $ hg clone -r alpha gitrepo hgrepo-a | grep -v '^updating' importing git objects into hg 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ cd hgrepo-a $ hg log --graph | egrep -v ': *(beta|master)' @ changeset: 0:3442585be8a6 tag: alpha tag: default/master tag: tip user: test <test@example.org> date: Mon Jan 01 00:00:10 2007 +0000 summary: add alpha $ cd .. $ echo % clone a branch % clone a branch $ hg clone -r beta gitrepo hgrepo-b | grep -v '^updating' importing git objects into hg 2 files updated, 0 files merged, 0 files removed, 0 files unresolved $ cd hgrepo-b $ hg log --graph | egrep -v ': *(beta|master)' @ changeset: 1:7bcd915dc873 | tag: default/beta | tag: tip | user: test <test@example.org> | date: Mon Jan 01 00:00:11 2007 +0000 | summary: add beta | o changeset: 0:3442585be8a6 tag: alpha tag: default/master user: test <test@example.org> date: Mon Jan 01 00:00:10 2007 +0000 summary: add alpha $ cd ..