summaryrefslogtreecommitdiff
path: root/t/t1400-update-ref.sh
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2020-01-25 00:06:24 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-01-28 22:41:39 (GMT)
commite5d7b2f65cadf9caa2097083b3bed4f6bce32fb9 (patch)
treeee795cef0e50926ae80d26e07286ae5b6b4e206c /t/t1400-update-ref.sh
parenta0ba80001a42eeacae94e3503c3e7d4bf7f2f2e1 (diff)
downloadgit-e5d7b2f65cadf9caa2097083b3bed4f6bce32fb9.zip
git-e5d7b2f65cadf9caa2097083b3bed4f6bce32fb9.tar.gz
git-e5d7b2f65cadf9caa2097083b3bed4f6bce32fb9.tar.bz2
t1400: avoid "test" string comparisons
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>
Diffstat (limited to 't/t1400-update-ref.sh')
-rwxr-xr-xt/t1400-update-ref.sh36
1 files changed, 24 insertions, 12 deletions
diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh
index b815cdd..a86dd2f 100755
--- a/t/t1400-update-ref.sh
+++ b/t/t1400-update-ref.sh
@@ -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
'