t4205, t6006, t7102: make functions better readable
[gitweb.git] / t / t6006-rev-list-format.sh
index c66a07f8da5b22444a52b54a9300e0c1da01ffe6..b32405a760fe58990e16e977b41325e5b8de04fd 100755 (executable)
@@ -9,18 +9,19 @@ test_description='git rev-list --pretty=format test'
 . "$TEST_DIRECTORY"/lib-terminal.sh
 
 test_tick
-# String "added" in German (translated with Google Translate), encoded in UTF-8,
-# used as a commit log message below.
+# String "added" in German
+# (translated with Google Translate),
+# encoded in UTF-8, used as a commit log message below.
 added=$(printf "added (hinzugef\303\274gt) foo")
-added_iso88591=$(echo "$added" | iconv -f utf-8 -t iso-8859-1)
+added_iso88591=$(echo "$added" | iconv -f utf-8 -t iso8859-1)
 # same but "changed"
 changed=$(printf "changed (ge\303\244ndert) foo")
-changed_iso88591=$(echo "$changed" | iconv -f utf-8 -t iso-8859-1)
+changed_iso88591=$(echo "$changed" | iconv -f utf-8 -t iso8859-1)
 
 test_expect_success 'setup' '
        : >foo &&
        git add foo &&
-       git config i18n.commitEncoding iso-8859-1 &&
+       git config i18n.commitEncoding iso8859-1 &&
        git commit -m "$added_iso88591" &&
        head1=$(git rev-parse --verify HEAD) &&
        head1_short=$(git rev-parse --verify --short $head1) &&
@@ -35,26 +36,13 @@ test_expect_success 'setup' '
        git config --unset i18n.commitEncoding
 '
 
-# usage: test_format [failure] name format_string <expected_output
+# usage: test_format name format_string [failure] <expected_output
 test_format () {
-       must_fail=0
-       # if parameters count is more than 2 then test must fail
-       if test $# -gt 2
-       then
-               must_fail=1
-               # remove first parameter which is flag for test failure
-               shift
-       fi
        cat >expect.$1
-       name="format $1"
-       command="git rev-list --pretty=format:'$2' master >output.$1 &&
-               test_cmp expect.$1 output.$1"
-       if test $must_fail -eq 1
-       then
-               test_expect_failure "$name" "$command"
-       else
-               test_expect_success "$name" "$command"
-       fi
+       test_expect_${3:-success} "format $1" "
+               git rev-list --pretty=format:'$2' master >output.$1 &&
+               test_cmp expect.$1 output.$1
+       "
 }
 
 # Feed to --format to provide predictable colored sequences.
@@ -136,12 +124,12 @@ EOF
 
 test_format encoding %e <<EOF
 commit $head2
-iso-8859-1
+iso8859-1
 commit $head1
-iso-8859-1
+iso8859-1
 EOF
 
-test_format failure subject %s <<EOF
+test_format subject %s <<EOF
 commit $head2
 $changed
 commit $head1
@@ -153,7 +141,7 @@ commit $head2
 commit $head1
 EOF
 
-test_format failure raw-body %B <<EOF
+test_format raw-body %B <<EOF
 commit $head2
 $changed
 
@@ -242,12 +230,12 @@ test_format complex-encoding %e <<EOF
 commit $head3
 iso8859-1
 commit $head2
-iso-8859-1
+iso8859-1
 commit $head1
-iso-8859-1
+iso8859-1
 EOF
 
-test_format failure complex-subject %s <<EOF
+test_format complex-subject %s <<EOF
 commit $head3
 Test printing of complex bodies
 commit $head2
@@ -256,7 +244,7 @@ commit $head1
 $added
 EOF
 
-test_format failure complex-body %b <<EOF
+test_format complex-body %b <<EOF
 commit $head3
 This commit message is much longer than the others,
 and it will be encoded in iso8859-1. We should therefore