Skip to content

Commit

Permalink
remote-helpers: tests: general improvements
Browse files Browse the repository at this point in the history
So that we don't need a temporary directory.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Felipe Contreras authored and Junio C Hamano committed May 28, 2013
1 parent dde67d7 commit 531594e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 45 deletions.
21 changes: 10 additions & 11 deletions contrib/remote-helpers/test-bzr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,11 @@ test_expect_success 'different authors' '
test_cmp expected actual
'

# cleanup previous stuff
rm -rf bzrrepo gitrepo

test_expect_success 'fetch utf-8 filenames' '
mkdir -p tmp && cd tmp &&
test_when_finished "cd .. && rm -rf tmp && LC_ALL=C" &&
test_when_finished "rm -rf bzrrepo gitrepo && LC_ALL=C" &&
LC_ALL=en_US.UTF-8
export LC_ALL
Expand Down Expand Up @@ -223,8 +225,9 @@ test_expect_success 'fetch utf-8 filenames' '
'

test_expect_success 'push utf-8 filenames' '
test_when_finished "rm -rf bzrrepo gitrepo && LC_ALL=C" &&
mkdir -p tmp && cd tmp &&
test_when_finished "cd .. && rm -rf tmp && LC_ALL=C" &&
LC_ALL=en_US.UTF-8
export LC_ALL
Expand Down Expand Up @@ -255,8 +258,7 @@ test_expect_success 'push utf-8 filenames' '
'

test_expect_success 'pushing a merge' '
mkdir -p tmp && cd tmp &&
test_when_finished "cd .. && rm -rf tmp" &&
test_when_finished "rm -rf bzrrepo gitrepo" &&
(
bzr init bzrrepo &&
Expand Down Expand Up @@ -297,8 +299,7 @@ origin/trunk
EOF

test_expect_success 'proper bzr repo' '
mkdir -p tmp && cd tmp &&
test_when_finished "cd .. && rm -rf tmp" &&
test_when_finished "rm -rf bzrrepo gitrepo" &&
bzr init-repo bzrrepo &&
Expand All @@ -323,13 +324,11 @@ test_expect_success 'proper bzr repo' '
git for-each-ref --format "%(refname:short)" refs/remotes/origin > ../actual
) &&
test_cmp ../expected actual
test_cmp expected actual
'

test_expect_success 'strip' '
# Do not imitate this style; always chdir inside a subshell instead
mkdir -p tmp && cd tmp &&
test_when_finished "cd .. && rm -rf tmp" &&
test_when_finished "rm -rf bzrrepo gitrepo" &&
(
bzr init bzrrepo &&
Expand Down
15 changes: 5 additions & 10 deletions contrib/remote-helpers/test-hg-bidi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ setup () {
setup

test_expect_success 'encoding' '
mkdir -p tmp && cd tmp &&
test_when_finished "cd .. && rm -rf tmp" &&
test_when_finished "rm -rf gitrepo* hgrepo*" &&
(
git init -q gitrepo &&
Expand Down Expand Up @@ -115,8 +114,7 @@ test_expect_success 'encoding' '
'

test_expect_success 'file removal' '
mkdir -p tmp && cd tmp &&
test_when_finished "cd .. && rm -rf tmp" &&
test_when_finished "rm -rf gitrepo* hgrepo*" &&
(
git init -q gitrepo &&
Expand Down Expand Up @@ -148,8 +146,7 @@ test_expect_success 'file removal' '
'

test_expect_success 'git tags' '
mkdir -p tmp && cd tmp &&
test_when_finished "cd .. && rm -rf tmp" &&
test_when_finished "rm -rf gitrepo* hgrepo*" &&
(
git init -q gitrepo &&
Expand Down Expand Up @@ -177,8 +174,7 @@ test_expect_success 'git tags' '
'

test_expect_success 'hg branch' '
mkdir -p tmp && cd tmp &&
test_when_finished "cd .. && rm -rf tmp" &&
test_when_finished "rm -rf gitrepo* hgrepo*" &&
(
git init -q gitrepo &&
Expand Down Expand Up @@ -214,8 +210,7 @@ test_expect_success 'hg branch' '
'

test_expect_success 'hg tags' '
mkdir -p tmp && cd tmp &&
test_when_finished "cd .. && rm -rf tmp" &&
test_when_finished "rm -rf gitrepo* hgrepo*" &&
(
git init -q gitrepo &&
Expand Down
33 changes: 11 additions & 22 deletions contrib/remote-helpers/test-hg-hg-git.sh
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ setup () {
setup

test_expect_success 'executable bit' '
mkdir -p tmp && cd tmp &&
test_when_finished "cd .. && rm -rf tmp" &&
test_when_finished "rm -rf gitrepo* hgrepo*" &&
(
git init -q gitrepo &&
Expand Down Expand Up @@ -151,8 +150,7 @@ test_expect_success 'executable bit' '
'

test_expect_success 'symlink' '
mkdir -p tmp && cd tmp &&
test_when_finished "cd .. && rm -rf tmp" &&
test_when_finished "rm -rf gitrepo* hgrepo*" &&
(
git init -q gitrepo &&
Expand Down Expand Up @@ -182,8 +180,7 @@ test_expect_success 'symlink' '
'

test_expect_success 'merge conflict 1' '
mkdir -p tmp && cd tmp &&
test_when_finished "cd .. && rm -rf tmp" &&
test_when_finished "rm -rf gitrepo* hgrepo*" &&
(
hg init hgrepo1 &&
Expand Down Expand Up @@ -217,8 +214,7 @@ test_expect_success 'merge conflict 1' '
'

test_expect_success 'merge conflict 2' '
mkdir -p tmp && cd tmp &&
test_when_finished "cd .. && rm -rf tmp" &&
test_when_finished "rm -rf gitrepo* hgrepo*" &&
(
hg init hgrepo1 &&
Expand Down Expand Up @@ -252,8 +248,7 @@ test_expect_success 'merge conflict 2' '
'

test_expect_success 'converged merge' '
mkdir -p tmp && cd tmp &&
test_when_finished "cd .. && rm -rf tmp" &&
test_when_finished "rm -rf gitrepo* hgrepo*" &&
(
hg init hgrepo1 &&
Expand Down Expand Up @@ -288,8 +283,7 @@ test_expect_success 'converged merge' '
'

test_expect_success 'encoding' '
mkdir -p tmp && cd tmp &&
test_when_finished "cd .. && rm -rf tmp" &&
test_when_finished "rm -rf gitrepo* hgrepo*" &&
(
git init -q gitrepo &&
Expand Down Expand Up @@ -328,8 +322,7 @@ test_expect_success 'encoding' '
'

test_expect_success 'file removal' '
mkdir -p tmp && cd tmp &&
test_when_finished "cd .. && rm -rf tmp" &&
test_when_finished "rm -rf gitrepo* hgrepo*" &&
(
git init -q gitrepo &&
Expand Down Expand Up @@ -368,8 +361,7 @@ test_expect_success 'file removal' '
'

test_expect_success 'git tags' '
mkdir -p tmp && cd tmp &&
test_when_finished "cd .. && rm -rf tmp" &&
test_when_finished "rm -rf gitrepo* hgrepo*" &&
(
git init -q gitrepo &&
Expand All @@ -395,8 +387,7 @@ test_expect_success 'git tags' '
'

test_expect_success 'hg author' '
mkdir -p tmp && cd tmp &&
test_when_finished "cd .. && rm -rf tmp" &&
test_when_finished "rm -rf gitrepo* hgrepo*" &&
for x in hg git; do
(
Expand Down Expand Up @@ -462,8 +453,7 @@ test_expect_success 'hg author' '
'

test_expect_success 'hg branch' '
mkdir -p tmp && cd tmp &&
test_when_finished "cd .. && rm -rf tmp" &&
test_when_finished "rm -rf gitrepo* hgrepo*" &&
for x in hg git; do
(
Expand Down Expand Up @@ -499,8 +489,7 @@ test_expect_success 'hg branch' '
'

test_expect_success 'hg tags' '
mkdir -p tmp && cd tmp &&
test_when_finished "cd .. && rm -rf tmp" &&
test_when_finished "rm -rf gitrepo* hgrepo*" &&
for x in hg git; do
(
Expand Down
7 changes: 5 additions & 2 deletions contrib/remote-helpers/test-hg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,17 @@ test_expect_success 'update bookmark' '
hg -R hgrepo bookmarks | egrep "devel[ ]+3:"
'

# cleanup previous stuff
rm -rf hgrepo

author_test () {
echo $1 >> content &&
hg commit -u "$2" -m "add $1" &&
echo "$3" >> ../expected
}

test_expect_success 'authors' '
mkdir -p tmp && cd tmp &&
test_when_finished "cd .. && rm -rf tmp" &&
test_when_finished "rm -rf hgrepo gitrepo" &&
(
hg init hgrepo &&
Expand All @@ -139,6 +141,7 @@ test_expect_success 'authors' '
touch content &&
hg add content &&
> ../expected &&
author_test alpha "" "H G Wells <wells@example.com>" &&
author_test beta "test" "test <unknown>" &&
author_test beta "test <test@example.com> (comment)" "test <test@example.com>" &&
Expand Down

0 comments on commit 531594e

Please sign in to comment.