changeset 578:935c4fb1bbfc

tests: let git init create directories when applicable It's functionally equivalent to create a directory, cd into it, git init, and cd out of the directory, or simply git init with the directory specified. In several cases, we were doing the former without performing any other operations in the git repo, which just made the test unneccesarily complex. Even in the case where we still want to cd into the directory, calling git init with the directory name eliminates the need for a separate mkdir command. This changeset converts the former approach to the latter with the goal of increasing the readability of the tests. Thanks to Felipe Contreras for the patch which this was based on.
author David M. Carr <david@carrclan.us>
date Wed, 31 Oct 2012 00:01:03 -0400
parents daf3e44a4aa9
children 675f19af79ca
files tests/test-clone.t tests/test-conflict-1.t tests/test-conflict-2.t tests/test-convergedmerge.t tests/test-empty-working-tree.t tests/test-encoding.t tests/test-file-removal.t tests/test-git-clone.t tests/test-git-submodules.t tests/test-git-tags.t tests/test-git-workflow.t tests/test-hg-author.t tests/test-hg-branch.t tests/test-hg-tags.t tests/test-incoming.t tests/test-keywords.t tests/test-merge.t tests/test-octopus.t tests/test-outgoing.t tests/test-pull-after-strip.t tests/test-push.t tests/test-subrepos.t tests/test-tree-decomposition.t
diffstat 23 files changed, 52 insertions(+), 114 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test-clone.t
+++ b/tests/test-clone.t
@@ -7,10 +7,9 @@
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ mkdir gitrepo
+  $ git init gitrepo
+  Initialized empty Git repository in $TESTTMP/gitrepo/.git/
   $ cd gitrepo
-  $ git init
-  Initialized empty Git repository in $TESTTMP/gitrepo/.git/
   $ echo alpha > alpha
   $ git add alpha
   $ fn_git_commit -m 'add alpha'
--- a/tests/test-conflict-1.t
+++ b/tests/test-conflict-1.t
@@ -48,13 +48,9 @@
 
   $ cd ..
 
-  $ mkdir gitrepo
-  $ cd gitrepo
-  $ git init --bare
+  $ git init --bare gitrepo
   Initialized empty Git repository in $TESTTMP/gitrepo/
 
-  $ cd ..
-
   $ cd hgrepo1
   $ hg bookmark -r tip master
   $ hg push -r master ../gitrepo
--- a/tests/test-conflict-2.t
+++ b/tests/test-conflict-2.t
@@ -48,13 +48,9 @@
 
   $ cd ..
 
-  $ mkdir gitrepo
-  $ cd gitrepo
-  $ git init --bare
+  $ git init --bare gitrepo
   Initialized empty Git repository in $TESTTMP/gitrepo/
 
-  $ cd ..
-
   $ cd hgrepo1
   $ hg bookmark -r tip master
   $ hg push -r master ../gitrepo
--- a/tests/test-convergedmerge.t
+++ b/tests/test-convergedmerge.t
@@ -49,13 +49,9 @@
 
   $ cd ..
 
-  $ mkdir gitrepo
-  $ cd gitrepo
-  $ git init --bare
+  $ git init --bare gitrepo
   Initialized empty Git repository in $TESTTMP/gitrepo/
 
-  $ cd ..
-
   $ cd hgrepo1
   $ hg bookmark -r4 master
   $ hg push -r master ../gitrepo
--- a/tests/test-empty-working-tree.t
+++ b/tests/test-empty-working-tree.t
@@ -7,20 +7,15 @@
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ mkdir gitrepo
+  $ git init gitrepo
+  Initialized empty Git repository in $TESTTMP/gitrepo/.git/
   $ cd gitrepo
-  $ git init
-  Initialized empty Git repository in $TESTTMP/gitrepo/.git/
-
   $ git commit --allow-empty -m empty >/dev/null 2>/dev/null || echo "git commit error"
 
   $ cd ..
-  $ mkdir gitrepo2
-  $ cd gitrepo2
-  $ git init --bare
+  $ git init --bare gitrepo2
   Initialized empty Git repository in $TESTTMP/gitrepo2/
 
-  $ cd ..
   $ hg clone gitrepo hgrepo | grep -v '^updating'
   importing git objects into hg
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
--- a/tests/test-encoding.t
+++ b/tests/test-encoding.t
@@ -25,10 +25,9 @@
   >     count=`expr $count + 1`
   > }
 
-  $ mkdir gitrepo
+  $ git init gitrepo
+  Initialized empty Git repository in $TESTTMP/gitrepo/.git/
   $ cd gitrepo
-  $ git init
-  Initialized empty Git repository in $TESTTMP/gitrepo/.git/
 
 utf-8 encoded commit message
   $ echo alpha > alpha
@@ -44,12 +43,9 @@
   variable i18n.commitencoding to the encoding your project uses.
 
   $ cd ..
-  $ mkdir gitrepo2
-  $ cd gitrepo2
-  $ git init --bare
+  $ git init --bare gitrepo2
   Initialized empty Git repository in $TESTTMP/gitrepo2/
 
-  $ cd ..
   $ hg clone gitrepo hgrepo | grep -v '^updating'
   importing git objects into hg
   4 files updated, 0 files merged, 0 files removed, 0 files unresolved
--- a/tests/test-file-removal.t
+++ b/tests/test-file-removal.t
@@ -7,10 +7,9 @@
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ mkdir gitrepo
+  $ git init gitrepo
+  Initialized empty Git repository in $TESTTMP/gitrepo/.git/
   $ cd gitrepo
-  $ git init
-  Initialized empty Git repository in $TESTTMP/gitrepo/.git/
   $ echo alpha > alpha
   $ git add alpha
   $ fn_git_commit -m 'add alpha'
@@ -33,12 +32,9 @@
   beta
 
   $ cd ..
-  $ mkdir gitrepo2
-  $ cd gitrepo2
-  $ git init --bare
+  $ git init --bare gitrepo2
   Initialized empty Git repository in $TESTTMP/gitrepo2/
 
-  $ 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
--- a/tests/test-git-clone.t
+++ b/tests/test-git-clone.t
@@ -7,10 +7,9 @@
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ mkdir gitrepo
+  $ git init gitrepo
+  Initialized empty Git repository in $TESTTMP/gitrepo/.git/
   $ cd gitrepo
-  $ git init
-  Initialized empty Git repository in $TESTTMP/gitrepo/.git/
   $ echo alpha > alpha
   $ git add alpha
   $ fn_git_commit -m 'add alpha'
--- a/tests/test-git-submodules.t
+++ b/tests/test-git-submodules.t
@@ -7,19 +7,17 @@
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ mkdir gitrepo1
+  $ git init gitrepo1
+  Initialized empty Git repository in $TESTTMP/gitrepo1/.git/
   $ cd gitrepo1
-  $ git init
-  Initialized empty Git repository in $TESTTMP/gitrepo1/.git/
   $ echo alpha > alpha
   $ git add alpha
   $ fn_git_commit -m 'add alpha'
   $ cd ..
 
-  $ mkdir gitsubrepo
+  $ git init gitsubrepo
+  Initialized empty Git repository in $TESTTMP/gitsubrepo/.git/
   $ cd gitsubrepo
-  $ git init
-  Initialized empty Git repository in $TESTTMP/gitsubrepo/.git/
   $ echo beta > beta
   $ git add beta
   $ fn_git_commit -m 'add beta'
--- a/tests/test-git-tags.t
+++ b/tests/test-git-tags.t
@@ -7,10 +7,9 @@
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ mkdir gitrepo
+  $ git init gitrepo
+  Initialized empty Git repository in $TESTTMP/gitrepo/.git/
   $ cd gitrepo
-  $ git init
-  Initialized empty Git repository in $TESTTMP/gitrepo/.git/
   $ git config receive.denyCurrentBranch ignore
   $ echo alpha > alpha
   $ git add alpha
--- a/tests/test-git-workflow.t
+++ b/tests/test-git-workflow.t
@@ -7,10 +7,8 @@
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ mkdir hgrepo
+  $ hg init hgrepo
   $ cd hgrepo
-  $ hg init
-
   $ echo alpha > alpha
   $ hg add alpha
   $ fn_hg_commit -m "add alpha"
--- a/tests/test-hg-author.t
+++ b/tests/test-hg-author.t
@@ -7,11 +7,9 @@
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ mkdir gitrepo
+  $ git init gitrepo
+  Initialized empty Git repository in $TESTTMP/gitrepo/.git/
   $ cd gitrepo
-  $ git init
-  Initialized empty Git repository in $TESTTMP/gitrepo/.git/
-
   $ echo alpha > alpha
   $ git add alpha
   $ fn_git_commit -m "add alpha"
--- a/tests/test-hg-branch.t
+++ b/tests/test-hg-branch.t
@@ -11,11 +11,9 @@
   $ filterhash="sed s/71414c4e3c6f/a31e374801c9/;s/698615204564/d93a72262a83/"
   $ filterhash="$filterhash;s/d93a72262a83/05aed681ccb3/"
 
-  $ mkdir gitrepo
+  $ git init gitrepo
+  Initialized empty Git repository in $TESTTMP/gitrepo/.git/
   $ cd gitrepo
-  $ git init
-  Initialized empty Git repository in $TESTTMP/gitrepo/.git/
-
   $ echo alpha > alpha
   $ git add alpha
   $ fn_git_commit -m "add alpha"
--- a/tests/test-hg-tags.t
+++ b/tests/test-hg-tags.t
@@ -7,11 +7,9 @@
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ mkdir gitrepo
+  $ git init gitrepo
+  Initialized empty Git repository in $TESTTMP/gitrepo/.git/
   $ cd gitrepo
-  $ git init
-  Initialized empty Git repository in $TESTTMP/gitrepo/.git/
-
   $ echo alpha > alpha
   $ git add alpha
   $ fn_git_commit -m "add alpha"
--- a/tests/test-incoming.t
+++ b/tests/test-incoming.t
@@ -11,11 +11,9 @@
   $ python -c 'from mercurial import util ; assert \
   >  util.version() != "unknown" and util.version() > "1.7"' || exit 80
 
-  $ mkdir gitrepo
+  $ git init gitrepo
+  Initialized empty Git repository in $TESTTMP/gitrepo/.git/
   $ cd gitrepo
-  $ git init
-  Initialized empty Git repository in $TESTTMP/gitrepo/.git/
-
   $ echo alpha > alpha
   $ git add alpha
   $ fn_git_commit -m "add alpha"
--- a/tests/test-keywords.t
+++ b/tests/test-keywords.t
@@ -7,10 +7,9 @@
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ mkdir gitrepo
+  $ git init gitrepo
+  Initialized empty Git repository in $TESTTMP/gitrepo/.git/
   $ cd gitrepo
-  $ git init
-  Initialized empty Git repository in $TESTTMP/gitrepo/.git/
   $ echo alpha > alpha
   $ git add alpha
   $ fn_git_commit -m 'add alpha'
--- a/tests/test-merge.t
+++ b/tests/test-merge.t
@@ -7,10 +7,9 @@
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ mkdir gitrepo
+  $ git init gitrepo
+  Initialized empty Git repository in $TESTTMP/gitrepo/.git/
   $ cd gitrepo
-  $ git init
-  Initialized empty Git repository in $TESTTMP/gitrepo/.git/
   $ echo alpha > alpha
   $ git add alpha
   $ fn_git_commit -m 'add alpha'
@@ -35,12 +34,9 @@
    create mode 100644 beta
 
   $ cd ..
-  $ mkdir gitrepo2
-  $ cd gitrepo2
-  $ git init --bare
+  $ git init --bare gitrepo2
   Initialized empty Git repository in $TESTTMP/gitrepo2/
 
-  $ cd ..
   $ hg clone gitrepo hgrepo | grep -v '^updating'
   importing git objects into hg
   3 files updated, 0 files merged, 0 files removed, 0 files unresolved
--- a/tests/test-octopus.t
+++ b/tests/test-octopus.t
@@ -7,11 +7,9 @@
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ mkdir gitrepo
+  $ git init gitrepo
+  Initialized empty Git repository in $TESTTMP/gitrepo/.git/
   $ cd gitrepo
-  $ git init
-  Initialized empty Git repository in $TESTTMP/gitrepo/.git/
-
   $ echo alpha > alpha
   $ git add alpha
   $ fn_git_commit -m 'add alpha'
@@ -45,12 +43,9 @@
    create mode 100644 gamma
 
   $ cd ..
-  $ mkdir gitrepo2
-  $ cd gitrepo2
-  $ git init --bare
+  $ git init --bare gitrepo2
   Initialized empty Git repository in $TESTTMP/gitrepo2/
 
-  $ cd ..
   $ hg clone gitrepo hgrepo | grep -v '^updating'
   importing git objects into hg
   4 files updated, 0 files merged, 0 files removed, 0 files unresolved
--- a/tests/test-outgoing.t
+++ b/tests/test-outgoing.t
@@ -7,11 +7,9 @@
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ mkdir gitrepo
+  $ git init gitrepo
+  Initialized empty Git repository in $TESTTMP/gitrepo/.git/
   $ cd gitrepo
-  $ git init
-  Initialized empty Git repository in $TESTTMP/gitrepo/.git/
-
   $ echo alpha > alpha
   $ git add alpha
   $ fn_git_commit -m "add alpha"
--- a/tests/test-pull-after-strip.t
+++ b/tests/test-pull-after-strip.t
@@ -18,10 +18,9 @@
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ mkdir gitrepo
+  $ git init gitrepo
+  Initialized empty Git repository in $TESTTMP/gitrepo/.git/
   $ cd gitrepo
-  $ git init
-  Initialized empty Git repository in $TESTTMP/gitrepo/.git/
   $ echo alpha > alpha
   $ git add alpha
   $ fn_git_commit -m 'add alpha'
--- a/tests/test-push.t
+++ b/tests/test-push.t
@@ -7,11 +7,9 @@
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ mkdir gitrepo
+  $ git init gitrepo
+  Initialized empty Git repository in $TESTTMP/gitrepo/.git/
   $ cd gitrepo
-  $ git init
-  Initialized empty Git repository in $TESTTMP/gitrepo/.git/
-
   $ echo alpha > alpha
   $ git add alpha
   $ fn_git_commit -m "add alpha"
--- a/tests/test-subrepos.t
+++ b/tests/test-subrepos.t
@@ -7,19 +7,17 @@
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ mkdir gitsubrepo
+  $ git init gitsubrepo
+  Initialized empty Git repository in $TESTTMP/gitsubrepo/.git/
   $ cd gitsubrepo
-  $ git init
-  Initialized empty Git repository in $TESTTMP/gitsubrepo/.git/
   $ echo beta > beta
   $ git add beta
   $ fn_git_commit -m 'add beta'
   $ cd ..
 
-  $ mkdir gitrepo1
+  $ git init gitrepo1
+  Initialized empty Git repository in $TESTTMP/gitrepo1/.git/
   $ cd gitrepo1
-  $ git init
-  Initialized empty Git repository in $TESTTMP/gitrepo1/.git/
   $ echo alpha > alpha
   $ git add alpha
   $ fn_git_commit -m 'add alpha'
--- a/tests/test-tree-decomposition.t
+++ b/tests/test-tree-decomposition.t
@@ -7,11 +7,9 @@
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ mkdir gitrepo
+  $ git init gitrepo
+  Initialized empty Git repository in $TESTTMP/gitrepo/.git/
   $ cd gitrepo
-  $ git init
-  Initialized empty Git repository in $TESTTMP/gitrepo/.git/
-
   $ mkdir d1
   $ echo a > d1/f1
   $ echo b > d1/f2
@@ -29,12 +27,9 @@
 
 
   $ cd ..
-  $ mkdir gitrepo2
-  $ cd gitrepo2
-  $ git init --bare
+  $ git init --bare gitrepo2
   Initialized empty Git repository in $TESTTMP/gitrepo2/
 
-  $ cd ..
   $ hg clone gitrepo hgrepo | grep -v '^updating'
   importing git objects into hg
   2 files updated, 0 files merged, 0 files removed, 0 files unresolved