Commits

David Carr committed a7da97e

tests: extract extension configuration into a testutil library

Thanks to Felipe Contreras for the patch which this was based on.

Even though the MQ extension was only used in a single test
(test-pull-after-strip.t), I included it in the testutil. It shouldn't hurt
anything to have it enabled and not used, and saves us from having to deal
with enabling extensions in individual tests at all.

Similarly, this changeset results in the graphlog extension being enabled
for all tests, even though there were some that didn't use it before. This is
even less significant in Mercurial 2.3+, since in those versions, graphlog is
part of core, and is available even when the extension is disabled.

Comments (0)

Files changed (28)

tests/test-bookmark-workflow.t

 of bookmarks should be considered "under test", and mutation of bookmarks
 locally is only to provide a test fixture.
 
+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
   $ python -c 'from mercurial import util ; assert \
   >  util.version() != "unknown" and util.version() >= "2.1"' || exit 80
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-
   $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
   $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
   $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE

tests/test-clone.t

+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-  $ echo 'hgext.graphlog =' >> $HGRCPATH
-
   $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
   $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
   $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE

tests/test-conflict-1.t

+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-  $ echo 'hgext.graphlog =' >> $HGRCPATH
-
   $ hg init hgrepo1
   $ cd hgrepo1
   $ echo A > afile

tests/test-conflict-2.t

+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-  $ echo 'hgext.graphlog =' >> $HGRCPATH
-
   $ hg init hgrepo1
   $ cd hgrepo1
   $ echo A > afile

tests/test-convergedmerge.t

+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-  $ echo 'hgext.graphlog =' >> $HGRCPATH
-
   $ hg init hgrepo1
   $ cd hgrepo1
   $ echo A > afile

tests/test-empty-working-tree.t

+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-
   $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
   $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
   $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE

tests/test-encoding.t

 # -*- coding: utf-8 -*-
 
+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-  $ echo 'hgext.graphlog =' >> $HGRCPATH
-
   $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
   $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
   $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE

tests/test-file-removal.t

+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-  $ echo 'hgext.graphlog =' >> $HGRCPATH
-
   $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
   $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
   $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE

tests/test-git-clone.t

+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-  $ echo 'hgext.graphlog =' >> $HGRCPATH
-
   $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
   $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
   $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE

tests/test-git-submodules.t

+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-  $ echo 'hgext.graphlog =' >> $HGRCPATH
-
   $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
   $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
   $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE

tests/test-git-tags.t

+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-  $ echo 'hgext.graphlog =' >> $HGRCPATH
-
   $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
   $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
   $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE

tests/test-git-workflow.t

+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-  $ echo 'hgext.graphlog =' >> $HGRCPATH
-
   $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
   $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
   $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE

tests/test-help.t

 Tests that the various help files are properly registered
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
 
   $ hg help | grep 'git' | sed 's/  */ /g'
    hggit push and pull from a Git server

tests/test-hg-author.t

+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-  $ echo 'hgext.graphlog =' >> $HGRCPATH
-
   $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
   $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
   $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE

tests/test-hg-branch.t

+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-  $ echo 'hgext.graphlog =' >> $HGRCPATH
-
   $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
   $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
   $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE

tests/test-hg-tags.t

+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-  $ echo 'hgext.graphlog =' >> $HGRCPATH
-
   $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
   $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
   $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE

tests/test-incoming.t

+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
   $ python -c 'from mercurial import util ; assert \
   >  util.version() != "unknown" and util.version() > "1.7"' || exit 80
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-  $ echo 'hgext.graphlog =' >> $HGRCPATH
-
   $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
   $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
   $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE

tests/test-keywords.t

+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-
   $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
   $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
   $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE

tests/test-merge.t

+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-  $ echo 'hgext.graphlog =' >> $HGRCPATH
-
   $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
   $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
   $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE

tests/test-octopus.t

+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-  $ echo 'hgext.graphlog =' >> $HGRCPATH
-
   $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
   $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
   $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE

tests/test-outgoing.t

+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-  $ echo 'hgext.graphlog =' >> $HGRCPATH
-
   $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
   $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
   $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE

tests/test-pull-after-strip.t

+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ cat >> $HGRCPATH <<EOF
-  > [extensions]
-  > graphlog=
-  > mq=
-  > EOF
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-
   $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
   $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
   $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE

tests/test-pull.t

+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-  $ echo 'hgext.graphlog =' >> $HGRCPATH
-
   $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
   $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
   $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE

tests/test-push-r.t

+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-  $ echo 'hgext.graphlog =' >> $HGRCPATH
-
   $ hg init test
   $ cd test
   $ cat >>afile <<EOF

tests/test-push.t

+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-  $ echo 'hgext.graphlog =' >> $HGRCPATH
-
   $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
   $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
   $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE

tests/test-subrepos.t

+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-
   $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
   $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
   $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE

tests/test-tree-decomposition.t

+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-
   $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
   $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
   $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE
+#!/bin/sh
+
+# This file holds logic that is used in many tests.
+# It can be called in a test like this:
+#  $ . "$TESTDIR/testutil"
+
+# Activate extensions
+echo "[extensions]" >> $HGRCPATH
+echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
+# Not needed in Mercurial 2.3+, as graphlog was integrated into core
+echo 'graphlog=' >> $HGRCPATH
+echo 'mq=' >> $HGRCPATH