]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t1400: avoid "test" string comparisons
authorJeff King <peff@peff.net>
Sat, 25 Jan 2020 00:06:24 +0000 (19:06 -0500)
committerJunio C Hamano <gitster@pobox.com>
Tue, 28 Jan 2020 22:41:39 +0000 (14:41 -0800)
Using the shell "test" here is inflexible, because we can't easily swap
it out for an i18n-aware version like we can with test_cmp and
test_i18ncmp. And it's not even saving us any processes, since we have
to use "cat" to get the output. So let's switch to using test_cmp, which
has the added bonus that it will produce better output if there's a
failure.

Note that not all of the changed outputs here are candidates for
translation, but I've converted all of them for consistency and to
benefit from the better output.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t1400-update-ref.sh

index b815cdd1b88052bdf98a0b371a25290461e58e02..a86dd2fbd9892e5a9f29a08e12ec6ee5ddc03cd1 100755 (executable)
@@ -361,55 +361,67 @@ ld="Thu, 26 May 2005 18:43:00 -0500"
 test_expect_success 'Query "master@{May 25 2005}" (before history)' '
        test_when_finished "rm -f o e" &&
        git rev-parse --verify "master@{May 25 2005}" >o 2>e &&
-       test $C = $(cat o) &&
-       test "warning: Log for '\''master'\'' only goes back to $ed." = "$(cat e)"
+       echo "$C" >expect &&
+       test_cmp expect o &&
+       echo "warning: Log for '\''master'\'' only goes back to $ed." >expect &&
+       test_cmp expect e
 '
 test_expect_success 'Query master@{2005-05-25} (before history)' '
        test_when_finished "rm -f o e" &&
        git rev-parse --verify master@{2005-05-25} >o 2>e &&
-       test $C = $(cat o) &&
-       test "warning: Log for '\''master'\'' only goes back to $ed." = "$(cat e)"
+       echo "$C" >expect &&
+       test_cmp expect o &&
+       echo "warning: Log for '\''master'\'' only goes back to $ed." >expect &&
+       test_cmp expect e
 '
 test_expect_success 'Query "master@{May 26 2005 23:31:59}" (1 second before history)' '
        test_when_finished "rm -f o e" &&
        git rev-parse --verify "master@{May 26 2005 23:31:59}" >o 2>e &&
-       test $C = $(cat o) &&
-       test "warning: Log for '\''master'\'' only goes back to $ed." = "$(cat e)"
+       echo "$C" >expect &&
+       test_cmp expect o &&
+       echo "warning: Log for '\''master'\'' only goes back to $ed." >expect &&
+       test_cmp expect e
 '
 test_expect_success 'Query "master@{May 26 2005 23:32:00}" (exactly history start)' '
        test_when_finished "rm -f o e" &&
        git rev-parse --verify "master@{May 26 2005 23:32:00}" >o 2>e &&
-       test $C = $(cat o) &&
+       echo "$C" >expect &&
+       test_cmp expect o &&
        test_must_be_empty e
 '
 test_expect_success 'Query "master@{May 26 2005 23:32:30}" (first non-creation change)' '
        test_when_finished "rm -f o e" &&
        git rev-parse --verify "master@{May 26 2005 23:32:30}" >o 2>e &&
-       test $A = $(cat o) &&
+       echo "$A" >expect &&
+       test_cmp expect o &&
        test_must_be_empty e
 '
 test_expect_success 'Query "master@{2005-05-26 23:33:01}" (middle of history with gap)' '
        test_when_finished "rm -f o e" &&
        git rev-parse --verify "master@{2005-05-26 23:33:01}" >o 2>e &&
-       test $B = $(cat o) &&
+       echo "$B" >expect &&
+       test_cmp expect o &&
        test_i18ngrep -F "warning: log for ref $m has gap after $gd" e
 '
 test_expect_success 'Query "master@{2005-05-26 23:38:00}" (middle of history)' '
        test_when_finished "rm -f o e" &&
        git rev-parse --verify "master@{2005-05-26 23:38:00}" >o 2>e &&
-       test $Z = $(cat o) &&
+       echo "$Z" >expect &&
+       test_cmp expect o &&
        test_must_be_empty e
 '
 test_expect_success 'Query "master@{2005-05-26 23:43:00}" (exact end of history)' '
        test_when_finished "rm -f o e" &&
        git rev-parse --verify "master@{2005-05-26 23:43:00}" >o 2>e &&
-       test $E = $(cat o) &&
+       echo "$E" >expect &&
+       test_cmp expect o &&
        test_must_be_empty e
 '
 test_expect_success 'Query "master@{2005-05-28}" (past end of history)' '
        test_when_finished "rm -f o e" &&
        git rev-parse --verify "master@{2005-05-28}" >o 2>e &&
-       test $D = $(cat o) &&
+       echo "$D" >expect &&
+       test_cmp expect o &&
        test_i18ngrep -F "warning: log for ref $m unexpectedly ended on $ld" e
 '