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>
Jeff King committed
Jan 24, 2020 at 19:06 UTC
e5d7b2f65cadf9caa2097083b3bed4f6bce32fb9
1 file changed
+24
-12
t/t1400-update-ref.sh
+24
-12
@@ -361,55 +361,67 @@ ld="Thu, 26 May 2005 18:43:00 -0500"
361
test_expect_success 'Query "master@{May 25 2005}" (before history)' '
362
test_when_finished "rm -f o e" &&
363
git rev-parse --verify "master@{May 25 2005}" >o 2>e &&
364
- test $C = $(cat o) &&
365
- test "warning: Log for '\''master'\'' only goes back to $ed." = "$(cat e)"
364
+ echo "$C" >expect &&
365
+ test_cmp expect o &&
366
+ echo "warning: Log for '\''master'\'' only goes back to $ed." >expect &&
367
+ test_cmp expect e
368
'
369
test_expect_success 'Query master@{2005-05-25} (before history)' '
370
test_when_finished "rm -f o e" &&
371
git rev-parse --verify master@{2005-05-25} >o 2>e &&
370
- test $C = $(cat o) &&
371
- test "warning: Log for '\''master'\'' only goes back to $ed." = "$(cat e)"
372
+ echo "$C" >expect &&
373
+ test_cmp expect o &&
374
+ echo "warning: Log for '\''master'\'' only goes back to $ed." >expect &&
375
+ test_cmp expect e
376
'
377
test_expect_success 'Query "master@{May 26 2005 23:31:59}" (1 second before history)' '
378
test_when_finished "rm -f o e" &&
379
git rev-parse --verify "master@{May 26 2005 23:31:59}" >o 2>e &&
376
- test $C = $(cat o) &&
377
- test "warning: Log for '\''master'\'' only goes back to $ed." = "$(cat e)"
380
+ echo "$C" >expect &&
381
+ test_cmp expect o &&
382
+ echo "warning: Log for '\''master'\'' only goes back to $ed." >expect &&
383
+ test_cmp expect e
384
'
385
test_expect_success 'Query "master@{May 26 2005 23:32:00}" (exactly history start)' '
386
test_when_finished "rm -f o e" &&
387
git rev-parse --verify "master@{May 26 2005 23:32:00}" >o 2>e &&
382
- test $C = $(cat o) &&
388
+ echo "$C" >expect &&
389
+ test_cmp expect o &&
390
test_must_be_empty e
391
'
392
test_expect_success 'Query "master@{May 26 2005 23:32:30}" (first non-creation change)' '
393
test_when_finished "rm -f o e" &&
394
git rev-parse --verify "master@{May 26 2005 23:32:30}" >o 2>e &&
388
- test $A = $(cat o) &&
395
+ echo "$A" >expect &&
396
+ test_cmp expect o &&
397
test_must_be_empty e
398
'
399
test_expect_success 'Query "master@{2005-05-26 23:33:01}" (middle of history with gap)' '
400
test_when_finished "rm -f o e" &&
401
git rev-parse --verify "master@{2005-05-26 23:33:01}" >o 2>e &&
394
- test $B = $(cat o) &&
402
+ echo "$B" >expect &&
403
+ test_cmp expect o &&
404
test_i18ngrep -F "warning: log for ref $m has gap after $gd" e
405
'
406
test_expect_success 'Query "master@{2005-05-26 23:38:00}" (middle of history)' '
407
test_when_finished "rm -f o e" &&
408
git rev-parse --verify "master@{2005-05-26 23:38:00}" >o 2>e &&
400
- test $Z = $(cat o) &&
409
+ echo "$Z" >expect &&
410
+ test_cmp expect o &&
411
test_must_be_empty e
412
'
413
test_expect_success 'Query "master@{2005-05-26 23:43:00}" (exact end of history)' '
414
test_when_finished "rm -f o e" &&
415
git rev-parse --verify "master@{2005-05-26 23:43:00}" >o 2>e &&
406
- test $E = $(cat o) &&
416
+ echo "$E" >expect &&
417
+ test_cmp expect o &&
418
test_must_be_empty e
419
'
420
test_expect_success 'Query "master@{2005-05-28}" (past end of history)' '
421
test_when_finished "rm -f o e" &&
422
git rev-parse --verify "master@{2005-05-28}" >o 2>e &&
412
- test $D = $(cat o) &&
423
+ echo "$D" >expect &&
424
+ test_cmp expect o &&
425
test_i18ngrep -F "warning: log for ref $m unexpectedly ended on $ld" e
426
'
427