contrib/remote-helpers: style updates for test scripts

During the review of the main series it was noticed that these test
scripts can use updates to conform to our coding style better, but
fixing the style should be done in a patch separate from the main
series.

This updates the test-*.sh scripts only for style issues:

 * We do not leave SP between a redirection operator and the
   filename;

 * We change line before "then", "do", etc. rather than terminating
   the condition for "if"/"while" and list for "for" with a
   semicolon;

 * When HERE document does not use any expansion, we quote the end
   marker (e.g. "cat <<\EOF" not "cat <<EOF") to signal the readers
   that there is no funny substitution to worry about when reading
   the code.

 * We use "test" rather than "[".

Reviewed-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Junio C Hamano
2013-08-29 14:10:04 -07:00
parent c587d65512
commit ff867963f0
4 changed files with 248 additions and 226 deletions

View File

@ -7,12 +7,14 @@ test_description='Test remote-bzr'
. ./test-lib.sh . ./test-lib.sh
if ! test_have_prereq PYTHON; then if ! test_have_prereq PYTHON
then
skip_all='skipping remote-bzr tests; python not available' skip_all='skipping remote-bzr tests; python not available'
test_done test_done
fi fi
if ! python -c 'import bzrlib'; then if ! python -c 'import bzrlib'
then
skip_all='skipping remote-bzr tests; bzr not available' skip_all='skipping remote-bzr tests; bzr not available'
test_done test_done
fi fi
@ -98,7 +100,7 @@ test_expect_success 'roundtrip' '
test_cmp expected actual test_cmp expected actual
' '
cat > expected <<EOF cat >expected <<\EOF
100644 blob 54f9d6da5c91d556e6b54340b1327573073030af content 100644 blob 54f9d6da5c91d556e6b54340b1327573073030af content
100755 blob 68769579c3eaadbe555379b9c3538e6628bae1eb executable 100755 blob 68769579c3eaadbe555379b9c3538e6628bae1eb executable
120000 blob 6b584e8ece562ebffc15d38808cd6b98fc3d97ea link 120000 blob 6b584e8ece562ebffc15d38808cd6b98fc3d97ea link
@ -136,7 +138,7 @@ test_expect_success 'special modes' '
test_cmp expected actual test_cmp expected actual
' '
cat > expected <<EOF cat >expected <<\EOF
100644 blob 54f9d6da5c91d556e6b54340b1327573073030af content 100644 blob 54f9d6da5c91d556e6b54340b1327573073030af content
100755 blob 68769579c3eaadbe555379b9c3538e6628bae1eb executable 100755 blob 68769579c3eaadbe555379b9c3538e6628bae1eb executable
120000 blob 6b584e8ece562ebffc15d38808cd6b98fc3d97ea link 120000 blob 6b584e8ece562ebffc15d38808cd6b98fc3d97ea link
@ -285,7 +287,7 @@ test_expect_success 'pushing a merge' '
test_cmp expected actual test_cmp expected actual
' '
cat > expected <<EOF cat >expected <<\EOF
origin/HEAD origin/HEAD
origin/branch origin/branch
origin/trunk origin/trunk

View File

@ -10,12 +10,14 @@ test_description='Test bidirectionality of remote-hg'
. ./test-lib.sh . ./test-lib.sh
if ! test_have_prereq PYTHON; then if ! test_have_prereq PYTHON
then
skip_all='skipping remote-hg tests; python not available' skip_all='skipping remote-hg tests; python not available'
test_done test_done
fi fi
if ! python -c 'import mercurial'; then if ! python -c 'import mercurial'
then
skip_all='skipping remote-hg tests; mercurial not available' skip_all='skipping remote-hg tests; mercurial not available'
test_done test_done
fi fi

View File

@ -10,17 +10,20 @@ test_description='Test remote-hg output compared to hg-git'
. ./test-lib.sh . ./test-lib.sh
if ! test_have_prereq PYTHON; then if ! test_have_prereq PYTHON
then
skip_all='skipping remote-hg tests; python not available' skip_all='skipping remote-hg tests; python not available'
test_done test_done
fi fi
if ! python -c 'import mercurial'; then if ! python -c 'import mercurial'
then
skip_all='skipping remote-hg tests; mercurial not available' skip_all='skipping remote-hg tests; mercurial not available'
test_done test_done
fi fi
if ! python -c 'import hggit'; then if ! python -c 'import hggit'
then
skip_all='skipping remote-hg tests; hg-git not available' skip_all='skipping remote-hg tests; hg-git not available'
test_done test_done
fi fi
@ -133,7 +136,8 @@ test_expect_success 'executable bit' '
git commit -m "clear executable bit" git commit -m "clear executable bit"
) && ) &&
for x in hg git; do for x in hg git
do
( (
hg_clone_$x gitrepo hgrepo-$x && hg_clone_$x gitrepo hgrepo-$x &&
cd hgrepo-$x && cd hgrepo-$x &&
@ -164,7 +168,8 @@ test_expect_success 'symlink' '
git commit -m "add beta" git commit -m "add beta"
) && ) &&
for x in hg git; do for x in hg git
do
( (
hg_clone_$x gitrepo hgrepo-$x && hg_clone_$x gitrepo hgrepo-$x &&
cd hgrepo-$x && cd hgrepo-$x &&
@ -203,7 +208,8 @@ test_expect_success 'merge conflict 1' '
hg ci -m "merge to C" hg ci -m "merge to C"
) && ) &&
for x in hg git; do for x in hg git
do
git_clone_$x hgrepo1 gitrepo-$x && git_clone_$x hgrepo1 gitrepo-$x &&
hg_clone_$x gitrepo-$x hgrepo2-$x && hg_clone_$x gitrepo-$x hgrepo2-$x &&
hg_log hgrepo2-$x >hg-log-$x && hg_log hgrepo2-$x >hg-log-$x &&
@ -237,7 +243,8 @@ test_expect_success 'merge conflict 2' '
hg ci -m "merge to B" hg ci -m "merge to B"
) && ) &&
for x in hg git; do for x in hg git
do
git_clone_$x hgrepo1 gitrepo-$x && git_clone_$x hgrepo1 gitrepo-$x &&
hg_clone_$x gitrepo-$x hgrepo2-$x && hg_clone_$x gitrepo-$x hgrepo2-$x &&
hg_log hgrepo2-$x >hg-log-$x && hg_log hgrepo2-$x >hg-log-$x &&
@ -272,7 +279,8 @@ test_expect_success 'converged merge' '
hg ci -m "merge" hg ci -m "merge"
) && ) &&
for x in hg git; do for x in hg git
do
git_clone_$x hgrepo1 gitrepo-$x && git_clone_$x hgrepo1 gitrepo-$x &&
hg_clone_$x gitrepo-$x hgrepo2-$x && hg_clone_$x gitrepo-$x hgrepo2-$x &&
hg_log hgrepo2-$x >hg-log-$x && hg_log hgrepo2-$x >hg-log-$x &&
@ -310,7 +318,8 @@ test_expect_success 'encoding' '
git commit -m "add déltà" git commit -m "add déltà"
) && ) &&
for x in hg git; do for x in hg git
do
hg_clone_$x gitrepo hgrepo-$x && hg_clone_$x gitrepo hgrepo-$x &&
git_clone_$x hgrepo-$x gitrepo2-$x && git_clone_$x hgrepo-$x gitrepo2-$x &&
@ -344,7 +353,8 @@ test_expect_success 'file removal' '
git commit -m "remove foo/bar" git commit -m "remove foo/bar"
) && ) &&
for x in hg git; do for x in hg git
do
( (
hg_clone_$x gitrepo hgrepo-$x && hg_clone_$x gitrepo hgrepo-$x &&
cd hgrepo-$x && cd hgrepo-$x &&
@ -379,7 +389,8 @@ test_expect_success 'git tags' '
git tag -a -m "added tag beta" beta git tag -a -m "added tag beta" beta
) && ) &&
for x in hg git; do for x in hg git
do
hg_clone_$x gitrepo hgrepo-$x && hg_clone_$x gitrepo hgrepo-$x &&
hg_log hgrepo-$x >log-$x hg_log hgrepo-$x >log-$x
done && done &&
@ -390,7 +401,8 @@ test_expect_success 'git tags' '
test_expect_success 'hg author' ' test_expect_success 'hg author' '
test_when_finished "rm -rf gitrepo* hgrepo*" && test_when_finished "rm -rf gitrepo* hgrepo*" &&
for x in hg git; do for x in hg git
do
( (
git init -q gitrepo-$x && git init -q gitrepo-$x &&
cd gitrepo-$x && cd gitrepo-$x &&
@ -456,7 +468,8 @@ test_expect_success 'hg author' '
test_expect_success 'hg branch' ' test_expect_success 'hg branch' '
test_when_finished "rm -rf gitrepo* hgrepo*" && test_when_finished "rm -rf gitrepo* hgrepo*" &&
for x in hg git; do for x in hg git
do
( (
git init -q gitrepo-$x && git init -q gitrepo-$x &&
cd gitrepo-$x && cd gitrepo-$x &&
@ -492,7 +505,8 @@ test_expect_success 'hg branch' '
test_expect_success 'hg tags' ' test_expect_success 'hg tags' '
test_when_finished "rm -rf gitrepo* hgrepo*" && test_when_finished "rm -rf gitrepo* hgrepo*" &&
for x in hg git; do for x in hg git
do
( (
git init -q gitrepo-$x && git init -q gitrepo-$x &&
cd gitrepo-$x && cd gitrepo-$x &&

View File

@ -10,12 +10,14 @@ test_description='Test remote-hg'
. ./test-lib.sh . ./test-lib.sh
if ! test_have_prereq PYTHON; then if ! test_have_prereq PYTHON
then
skip_all='skipping remote-hg tests; python not available' skip_all='skipping remote-hg tests; python not available'
test_done test_done
fi fi
if ! python -c 'import mercurial'; then if ! python -c 'import mercurial'
then
skip_all='skipping remote-hg tests; mercurial not available' skip_all='skipping remote-hg tests; mercurial not available'
test_done test_done
fi fi
@ -27,7 +29,8 @@ check () {
} }
check_branch () { check_branch () {
if [ -n "$3" ]; then if test -n "$3"
then
echo $3 >expected && echo $3 >expected &&
hg -R $1 log -r $2 --template '{desc}\n' >actual && hg -R $1 log -r $2 --template '{desc}\n' >actual &&
test_cmp expected actual test_cmp expected actual
@ -38,7 +41,8 @@ check_branch () {
} }
check_bookmark () { check_bookmark () {
if [ -n "$3" ]; then if test -n "$3"
then
echo $3 >expected && echo $3 >expected &&
hg -R $1 log -r "bookmark('$2')" --template '{desc}\n' >actual && hg -R $1 log -r "bookmark('$2')" --template '{desc}\n' >actual &&
test_cmp expected actual test_cmp expected actual
@ -282,7 +286,7 @@ test_expect_success 'remote push with master bookmark' '
check_branch hgrepo default two check_branch hgrepo default two
' '
cat > expected <<EOF cat >expected <<\EOF
changeset: 0:6e2126489d3d changeset: 0:6e2126489d3d
tag: tip tag: tip
user: A U Thor <author@example.com> user: A U Thor <author@example.com>
@ -382,7 +386,7 @@ test_expect_success 'remote push diverged' '
cd gitrepo && cd gitrepo &&
echo diverge >content && echo diverge >content &&
git commit -a -m diverged && git commit -a -m diverged &&
check_push 1 <<-EOF check_push 1 <<-\EOF
master:non-fast-forward master:non-fast-forward
EOF EOF
) && ) &&
@ -412,7 +416,7 @@ test_expect_success 'remote update bookmark diverge' '
git checkout --quiet diverge && git checkout --quiet diverge &&
echo diverge >content && echo diverge >content &&
git commit -a -m diverge && git commit -a -m diverge &&
check_push 1 <<-EOF check_push 1 <<-\EOF
diverge:fetch-first diverge:fetch-first
EOF EOF
) && ) &&
@ -509,7 +513,7 @@ test_expect_success 'remote big push' '
( (
cd gitrepo && cd gitrepo &&
check_push 1 --all <<-EOF check_push 1 --all <<-\EOF
master master
good_bmark good_bmark
branches/good_branch branches/good_branch
@ -577,7 +581,7 @@ test_expect_success 'remote big push fetch first' '
echo five >content && echo five >content &&
git commit -q -a -m five && git commit -q -a -m five &&
check_push 1 --all <<-EOF && check_push 1 --all <<-\EOF &&
master master
good_bmark good_bmark
bad_bmark:fetch-first bad_bmark:fetch-first
@ -586,7 +590,7 @@ test_expect_success 'remote big push fetch first' '
git fetch && git fetch &&
check_push 1 --all <<-EOF check_push 1 --all <<-\EOF
master master
good_bmark good_bmark
bad_bmark:non-fast-forward bad_bmark:non-fast-forward
@ -603,7 +607,7 @@ test_expect_failure 'remote big push force' '
( (
cd gitrepo && cd gitrepo &&
check_push 0 --force --all <<-EOF check_push 0 --force --all <<-\EOF
master master
good_bmark good_bmark
branches/good_branch branches/good_branch
@ -633,7 +637,7 @@ test_expect_failure 'remote big push dry-run' '
( (
cd gitrepo && cd gitrepo &&
check_push 1 --dry-run --all <<-EOF && check_push 1 --dry-run --all <<-\EOF &&
master master
good_bmark good_bmark
branches/good_branch branches/good_branch
@ -644,7 +648,7 @@ test_expect_failure 'remote big push dry-run' '
branches/bad_branch:non-fast-forward branches/bad_branch:non-fast-forward
EOF EOF
check_push 0 --dry-run master good_bmark new_bmark branches/good_branch branches/new_branch <<-EOF check_push 0 --dry-run master good_bmark new_bmark branches/good_branch branches/new_branch <<-\EOF
master master
good_bmark good_bmark
branches/good_branch branches/good_branch