annotate tests/testutil @ 970:a7956bcbffe1

testutil: clean up compat cruft
author Siddharth Agarwal <sid0@fb.com>
date Thu, 31 Dec 2015 13:02:34 -0800
parents eb9ebc7ed061
children b236d7259c2d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
575
a7da97e69d56 tests: extract extension configuration into a testutil library
David M. Carr <david@carrclan.us>
parents:
diff changeset
1 #!/bin/sh
a7da97e69d56 tests: extract extension configuration into a testutil library
David M. Carr <david@carrclan.us>
parents:
diff changeset
2
a7da97e69d56 tests: extract extension configuration into a testutil library
David M. Carr <david@carrclan.us>
parents:
diff changeset
3 # This file holds logic that is used in many tests.
a7da97e69d56 tests: extract extension configuration into a testutil library
David M. Carr <david@carrclan.us>
parents:
diff changeset
4 # It can be called in a test like this:
a7da97e69d56 tests: extract extension configuration into a testutil library
David M. Carr <david@carrclan.us>
parents:
diff changeset
5 # $ . "$TESTDIR/testutil"
a7da97e69d56 tests: extract extension configuration into a testutil library
David M. Carr <david@carrclan.us>
parents:
diff changeset
6
a7da97e69d56 tests: extract extension configuration into a testutil library
David M. Carr <david@carrclan.us>
parents:
diff changeset
7 # Activate extensions
a7da97e69d56 tests: extract extension configuration into a testutil library
David M. Carr <david@carrclan.us>
parents:
diff changeset
8 echo "[extensions]" >> $HGRCPATH
a7da97e69d56 tests: extract extension configuration into a testutil library
David M. Carr <david@carrclan.us>
parents:
diff changeset
9 echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
a7da97e69d56 tests: extract extension configuration into a testutil library
David M. Carr <david@carrclan.us>
parents:
diff changeset
10 echo 'mq=' >> $HGRCPATH
576
c4849b2dab87 tests: extract commonly used commit/tag functions into testutil library
David M. Carr <david@carrclan.us>
parents: 575
diff changeset
11
579
675f19af79ca tests: extract git command-line client and dulwich requirements into testutil
David M. Carr <david@carrclan.us>
parents: 576
diff changeset
12 # Standard checks for external dependencies
675f19af79ca tests: extract git command-line client and dulwich requirements into testutil
David M. Carr <david@carrclan.us>
parents: 576
diff changeset
13 # We use the git command-line client and dulwich in pretty much all the tests.
675f19af79ca tests: extract git command-line client and dulwich requirements into testutil
David M. Carr <david@carrclan.us>
parents: 576
diff changeset
14 # Thus, to avoid repetitively declaring that requirement in almost every test,
675f19af79ca tests: extract git command-line client and dulwich requirements into testutil
David M. Carr <david@carrclan.us>
parents: 576
diff changeset
15 # we just call the checks in all tests that include this library.
675f19af79ca tests: extract git command-line client and dulwich requirements into testutil
David M. Carr <david@carrclan.us>
parents: 576
diff changeset
16 python -c 'import dulwich' || {
675f19af79ca tests: extract git command-line client and dulwich requirements into testutil
David M. Carr <david@carrclan.us>
parents: 576
diff changeset
17 echo "skipped: missing feature: dulwich" && exit 80
675f19af79ca tests: extract git command-line client and dulwich requirements into testutil
David M. Carr <david@carrclan.us>
parents: 576
diff changeset
18 }
675f19af79ca tests: extract git command-line client and dulwich requirements into testutil
David M. Carr <david@carrclan.us>
parents: 576
diff changeset
19 "$TESTDIR/hghave" git || exit 80
675f19af79ca tests: extract git command-line client and dulwich requirements into testutil
David M. Carr <david@carrclan.us>
parents: 576
diff changeset
20
576
c4849b2dab87 tests: extract commonly used commit/tag functions into testutil library
David M. Carr <david@carrclan.us>
parents: 575
diff changeset
21 GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
c4849b2dab87 tests: extract commonly used commit/tag functions into testutil library
David M. Carr <david@carrclan.us>
parents: 575
diff changeset
22 GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
c4849b2dab87 tests: extract commonly used commit/tag functions into testutil library
David M. Carr <david@carrclan.us>
parents: 575
diff changeset
23 GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE
c4849b2dab87 tests: extract commonly used commit/tag functions into testutil library
David M. Carr <david@carrclan.us>
parents: 575
diff changeset
24 GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; export GIT_COMMITTER_NAME
c4849b2dab87 tests: extract commonly used commit/tag functions into testutil library
David M. Carr <david@carrclan.us>
parents: 575
diff changeset
25 GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"; export GIT_COMMITTER_EMAIL
c4849b2dab87 tests: extract commonly used commit/tag functions into testutil library
David M. Carr <david@carrclan.us>
parents: 575
diff changeset
26 GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"; export GIT_COMMITTER_DATE
c4849b2dab87 tests: extract commonly used commit/tag functions into testutil library
David M. Carr <david@carrclan.us>
parents: 575
diff changeset
27
c4849b2dab87 tests: extract commonly used commit/tag functions into testutil library
David M. Carr <david@carrclan.us>
parents: 575
diff changeset
28 # Functions to commit and tag in Mercurial and Git in a predictable manner
c4849b2dab87 tests: extract commonly used commit/tag functions into testutil library
David M. Carr <david@carrclan.us>
parents: 575
diff changeset
29 count=10
c4849b2dab87 tests: extract commonly used commit/tag functions into testutil library
David M. Carr <david@carrclan.us>
parents: 575
diff changeset
30
c4849b2dab87 tests: extract commonly used commit/tag functions into testutil library
David M. Carr <david@carrclan.us>
parents: 575
diff changeset
31 fn_git_commit() {
c4849b2dab87 tests: extract commonly used commit/tag functions into testutil library
David M. Carr <david@carrclan.us>
parents: 575
diff changeset
32 GIT_AUTHOR_DATE="2007-01-01 00:00:$count +0000"
c4849b2dab87 tests: extract commonly used commit/tag functions into testutil library
David M. Carr <david@carrclan.us>
parents: 575
diff changeset
33 GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
586
24d4741674a6 tests: use fn_git_commit in test-encoding.t
David M. Carr <david@carrclan.us>
parents: 579
diff changeset
34 git commit "$@" >/dev/null || echo "git commit error"
576
c4849b2dab87 tests: extract commonly used commit/tag functions into testutil library
David M. Carr <david@carrclan.us>
parents: 575
diff changeset
35 count=`expr $count + 1`
c4849b2dab87 tests: extract commonly used commit/tag functions into testutil library
David M. Carr <david@carrclan.us>
parents: 575
diff changeset
36 }
c4849b2dab87 tests: extract commonly used commit/tag functions into testutil library
David M. Carr <david@carrclan.us>
parents: 575
diff changeset
37
c4849b2dab87 tests: extract commonly used commit/tag functions into testutil library
David M. Carr <david@carrclan.us>
parents: 575
diff changeset
38 fn_hg_commit() {
c4849b2dab87 tests: extract commonly used commit/tag functions into testutil library
David M. Carr <david@carrclan.us>
parents: 575
diff changeset
39 HGDATE="2007-01-01 00:00:$count +0000"
586
24d4741674a6 tests: use fn_git_commit in test-encoding.t
David M. Carr <david@carrclan.us>
parents: 579
diff changeset
40 hg commit -d "$HGDATE" "$@" >/dev/null || echo "hg commit error"
576
c4849b2dab87 tests: extract commonly used commit/tag functions into testutil library
David M. Carr <david@carrclan.us>
parents: 575
diff changeset
41 count=`expr $count + 1`
c4849b2dab87 tests: extract commonly used commit/tag functions into testutil library
David M. Carr <david@carrclan.us>
parents: 575
diff changeset
42 }
c4849b2dab87 tests: extract commonly used commit/tag functions into testutil library
David M. Carr <david@carrclan.us>
parents: 575
diff changeset
43
760
eb9ebc7ed061 git_handler: store hg extra data in git deterministically by sorting it
Siddharth Agarwal <sid0@fb.com>
parents: 586
diff changeset
44 fn_hg_commitextra() {
eb9ebc7ed061 git_handler: store hg extra data in git deterministically by sorting it
Siddharth Agarwal <sid0@fb.com>
parents: 586
diff changeset
45 HGDATE="2007-01-01 00:00:$count +0000"
eb9ebc7ed061 git_handler: store hg extra data in git deterministically by sorting it
Siddharth Agarwal <sid0@fb.com>
parents: 586
diff changeset
46 hg --config extensions.commitextra=$TESTDIR/commitextra.py commitextra \
eb9ebc7ed061 git_handler: store hg extra data in git deterministically by sorting it
Siddharth Agarwal <sid0@fb.com>
parents: 586
diff changeset
47 -d "$HGDATE" "$@" >/dev/null || echo "hg commit error"
eb9ebc7ed061 git_handler: store hg extra data in git deterministically by sorting it
Siddharth Agarwal <sid0@fb.com>
parents: 586
diff changeset
48 count=`expr $count + 1`
eb9ebc7ed061 git_handler: store hg extra data in git deterministically by sorting it
Siddharth Agarwal <sid0@fb.com>
parents: 586
diff changeset
49 }
eb9ebc7ed061 git_handler: store hg extra data in git deterministically by sorting it
Siddharth Agarwal <sid0@fb.com>
parents: 586
diff changeset
50
576
c4849b2dab87 tests: extract commonly used commit/tag functions into testutil library
David M. Carr <david@carrclan.us>
parents: 575
diff changeset
51 fn_git_tag() {
c4849b2dab87 tests: extract commonly used commit/tag functions into testutil library
David M. Carr <david@carrclan.us>
parents: 575
diff changeset
52 GIT_AUTHOR_DATE="2007-01-01 00:00:$count +0000"
c4849b2dab87 tests: extract commonly used commit/tag functions into testutil library
David M. Carr <david@carrclan.us>
parents: 575
diff changeset
53 GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
586
24d4741674a6 tests: use fn_git_commit in test-encoding.t
David M. Carr <david@carrclan.us>
parents: 579
diff changeset
54 git tag "$@" >/dev/null || echo "git tag error"
576
c4849b2dab87 tests: extract commonly used commit/tag functions into testutil library
David M. Carr <david@carrclan.us>
parents: 575
diff changeset
55 count=`expr $count + 1`
c4849b2dab87 tests: extract commonly used commit/tag functions into testutil library
David M. Carr <david@carrclan.us>
parents: 575
diff changeset
56 }
c4849b2dab87 tests: extract commonly used commit/tag functions into testutil library
David M. Carr <david@carrclan.us>
parents: 575
diff changeset
57
c4849b2dab87 tests: extract commonly used commit/tag functions into testutil library
David M. Carr <david@carrclan.us>
parents: 575
diff changeset
58 fn_hg_tag() {
c4849b2dab87 tests: extract commonly used commit/tag functions into testutil library
David M. Carr <david@carrclan.us>
parents: 575
diff changeset
59 HGDATE="2007-01-01 00:00:$count +0000"
586
24d4741674a6 tests: use fn_git_commit in test-encoding.t
David M. Carr <david@carrclan.us>
parents: 579
diff changeset
60 hg tag -d "$HGDATE" "$@" >/dev/null || echo "hg tag error"
576
c4849b2dab87 tests: extract commonly used commit/tag functions into testutil library
David M. Carr <david@carrclan.us>
parents: 575
diff changeset
61 count=`expr $count + 1`
c4849b2dab87 tests: extract commonly used commit/tag functions into testutil library
David M. Carr <david@carrclan.us>
parents: 575
diff changeset
62 }