]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t4205, t6006, t7102: make functions better readable
authorAlexey Shumkin <alex.crezoff@gmail.com>
Fri, 5 Jul 2013 12:01:48 +0000 (16:01 +0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 5 Jul 2013 18:40:18 +0000 (11:40 -0700)
Function 'test_format' has become harder to read after its change in
de6029a2 (pretty: Add failing tests: --format output should honor
logOutputEncoding, 2013-06-26). Simplify it by moving its "should we
expect it to fail?" parameter to the end.

Note, current code does not use this last parameter as far as there
are no tests expected to fail. We can keep that for future use.

Also, reformat comments.

Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
Improved-by: Johannes Sixt <j.sixt@viscovery.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t4205-log-pretty-formats.sh
t/t6006-rev-list-format.sh
t/t7102-reset.sh

index ef9770a52b0e5940d1eabda07471aea1eb44c753..2933c637090e7efd8726847c0e782d71a4fe782b 100755 (executable)
@@ -8,7 +8,8 @@ test_description='Test pretty formats'
 . ./test-lib.sh
 
 commit_msg () {
-       # String "initial. initial" partly in German (translated with Google Translate),
+       # String "initial. initial" partly in German
+       # (translated with Google Translate),
        # encoded in UTF-8, used as a commit log message below.
        msg=$(printf "initial. anf\303\244nglich")
        if test -n "$1"
index 4751d222176d65d0fae82d9798827b2b8d2b9433..b32405a760fe58990e16e977b41325e5b8de04fd 100755 (executable)
@@ -9,8 +9,9 @@ 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 iso8859-1)
 # same but "changed"
@@ -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.
index 2ef96e92406406409f10788d827a1d937ce69561..4f1c9f9c7f8ad5aa25f6581815140598d1d6d45f 100755 (executable)
@@ -10,14 +10,16 @@ Documented tests for git reset'
 . ./test-lib.sh
 
 commit_msg () {
-       # String "modify 2nd file (changed)" partly in German(translated with Google Translate),
+       # String "modify 2nd file (changed)" partly in German
+       # (translated with Google Translate),
        # encoded in UTF-8, used as a commit log message below.
-       msg=$(printf "modify 2nd file (ge\303\244ndert)")
+       msg="modify 2nd file (ge\303\244ndert)\n"
        if test -n "$1"
        then
-               msg=$(echo $msg | iconv -f utf-8 -t $1)
+               printf "$msg" | iconv -f utf-8 -t "$1"
+       else
+               printf "$msg"
        fi
-       echo $msg
 }
 
 test_expect_success 'creating initial files and commits' '