view tests/test-hg-branch.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"

TODO stop using this when we're 1.5 only
  $ filterhash="sed s/71414c4e3c6f/a31e374801c9/;s/698615204564/d93a72262a83/"
  $ filterhash="$filterhash;s/d93a72262a83/05aed681ccb3/"

  $ 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 checkout -b not-master
  Switched to a new branch 'not-master'

  $ cd ..
  $ hg clone gitrepo hgrepo | grep -v '^updating'
  importing git objects into hg
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved

  $ cd hgrepo
  $ hg co master
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ hg mv alpha beta
  $ fn_hg_commit -m 'rename alpha to beta'
  $ hg push
  pushing to $TESTTMP/gitrepo
  searching for changes

  $ hg branch gamma | grep -v 'permanent and global'
  marked working directory as branch gamma
  $ fn_hg_commit -m 'started branch gamma'
  $ hg push
  pushing to $TESTTMP/gitrepo
  searching for changes

  $ hg log --graph | $filterhash | egrep -v ': *(not-master|master)'
  @  changeset:   2:05aed681ccb3
  |  branch:      gamma
  |  tag:         default/master
  |  tag:         tip
  |  user:        test
  |  date:        Mon Jan 01 00:00:12 2007 +0000
  |  summary:     started branch gamma
  |
  o  changeset:   1:a31e374801c9
  |  user:        test
  |  date:        Mon Jan 01 00:00:11 2007 +0000
  |  summary:     rename alpha to beta
  |
  o  changeset:   0:3442585be8a6
     tag:         default/not-master
     user:        test <test@example.org>
     date:        Mon Jan 01 00:00:10 2007 +0000
     summary:     add alpha
  

  $ 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
  $ hg log --graph | $filterhash | egrep -v ': *(not-master|master)'
  o  changeset:   2:05aed681ccb3
  |  branch:      gamma
  |  tag:         default/master
  |  tag:         tip
  |  user:        test
  |  date:        Mon Jan 01 00:00:12 2007 +0000
  |  summary:     started branch gamma
  |
  @  changeset:   1:a31e374801c9
  |  user:        test
  |  date:        Mon Jan 01 00:00:11 2007 +0000
  |  summary:     rename alpha to beta
  |
  o  changeset:   0:3442585be8a6
     tag:         default/not-master
     user:        test <test@example.org>
     date:        Mon Jan 01 00:00:10 2007 +0000
     summary:     add alpha
  

  $ cd ..