t6036, t6042: prefer test_cmp to sequences of test
Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Elijah Newren committed
May 24, 2018 at 00:04 UTC
6ac767e5c00a53a41460e3202fcce9e5b5b76c55
2 files changed
+130
-73
t/t6036-recursive-corner-cases.sh
+71
-38
@@ -72,11 +72,14 @@ test_expect_success 'merge simple rename+criss-cross with no modifications' '
72
git ls-files -o >out &&
73
test_line_count = 3 out &&
74
75
- test $(git rev-parse :2:three) = $(git rev-parse L2:three) &&
76
- test $(git rev-parse :3:three) = $(git rev-parse R2:three) &&
77
-
78
- test $(git rev-parse L2:three) = $(git hash-object three~HEAD) &&
79
- test $(git rev-parse R2:three) = $(git hash-object three~R2^0)
75
+ git rev-parse >expect \
76
+ L2:three R2:three \
77
+ L2:three R2:three &&
78
+ git rev-parse >actual \
79
+ :2:three :3:three &&
80
+ git hash-object >>actual \
81
+ three~HEAD three~R2^0
82
+ test_cmp expect actual
83
)
84
'
85
@@ -145,11 +148,14 @@ test_expect_success 'merge criss-cross + rename merges with basic modification'
148
git ls-files -o >out &&
149
test_line_count = 3 out &&
150
148
- test $(git rev-parse :2:three) = $(git rev-parse L2:three) &&
149
- test $(git rev-parse :3:three) = $(git rev-parse R2:three) &&
150
-
151
- test $(git rev-parse L2:three) = $(git hash-object three~HEAD) &&
152
- test $(git rev-parse R2:three) = $(git hash-object three~R2^0)
151
+ git rev-parse >expect \
152
+ L2:three R2:three \
153
+ L2:three R2:three &&
154
+ git rev-parse >actual \
155
+ :2:three :3:three &&
156
+ git hash-object >>actual \
157
+ three~HEAD three~R2^0
158
+ test_cmp expect actual
159
)
160
'
161
@@ -224,19 +230,23 @@ test_expect_success 'git detects differently handled merges conflict' '
230
git ls-files -o >out &&
231
test_line_count = 1 out &&
232
227
- test $(git rev-parse :2:new_a) = $(git rev-parse D:new_a) &&
228
- test $(git rev-parse :3:new_a) = $(git rev-parse E:new_a) &&
233
+ git rev-parse >expect \
234
+ D:new_a E:new_a &&
235
+ git rev-parse >actual \
236
+ :2:new_a :3:new_a &&
237
+ test_cmp expect actual
238
230
- git cat-file -p B:new_a >>merged &&
231
- git cat-file -p C:new_a >>merge-me &&
239
+ git cat-file -p B:new_a >ours &&
240
+ git cat-file -p C:new_a >theirs &&
241
>empty &&
242
test_must_fail git merge-file \
243
-L "Temporary merge branch 2" \
244
-L "" \
245
-L "Temporary merge branch 1" \
237
- merged empty merge-me &&
238
- sed -e "s/^\([<=>]\)/\1\1\1/" merged >merged-internal &&
239
- test $(git rev-parse :1:new_a) = $(git hash-object merged-internal)
246
+ ours empty theirs &&
247
+ sed -e "s/^\([<=>]\)/\1\1\1/" ours >expect &&
248
+ git cat-file -p :1:new_a >actual &&
249
+ test_cmp expect actual
250
)
251
'
252
@@ -311,8 +321,11 @@ test_expect_success 'git detects conflict merging criss-cross+modify/delete' '
321
git ls-files -u >out &&
322
test_line_count = 2 out &&
323
314
- test $(git rev-parse :1:file) = $(git rev-parse master:file) &&
315
- test $(git rev-parse :2:file) = $(git rev-parse B:file)
324
+ git rev-parse >expect \
325
+ master:file B:file &&
326
+ git rev-parse >actual \
327
+ :1:file :2:file &&
328
+ test_cmp expect actual
329
)
330
'
331
@@ -330,8 +343,11 @@ test_expect_success 'git detects conflict merging criss-cross+modify/delete, rev
343
git ls-files -u >out &&
344
test_line_count = 2 out &&
345
333
- test $(git rev-parse :1:file) = $(git rev-parse master:file) &&
334
- test $(git rev-parse :3:file) = $(git rev-parse B:file)
346
+ git rev-parse >expect \
347
+ master:file B:file &&
348
+ git rev-parse >actual \
349
+ :1:file :3:file &&
350
+ test_cmp expect actual
351
)
352
'
353
@@ -443,8 +459,11 @@ test_expect_success 'merge of D & E1 fails but has appropriate contents' '
459
git ls-files -o >out &&
460
test_line_count = 1 out &&
461
446
- test $(git rev-parse :0:ignore-me) = $(git rev-parse A:ignore-me) &&
447
- test $(git rev-parse :2:a) = $(git rev-parse B:a)
462
+ git rev-parse >expect \
463
+ A:ignore-me B:a &&
464
+ git rev-parse >actual \
465
+ :0:ignore-me :2:a &&
466
+ test_cmp expect actual
467
)
468
'
469
@@ -463,8 +482,11 @@ test_expect_success 'merge of E1 & D fails but has appropriate contents' '
482
git ls-files -o >out &&
483
test_line_count = 1 out &&
484
466
- test $(git rev-parse :0:ignore-me) = $(git rev-parse A:ignore-me) &&
467
- test $(git rev-parse :3:a) = $(git rev-parse B:a)
485
+ git rev-parse >expect \
486
+ A:ignore-me B:a &&
487
+ git rev-parse >actual \
488
+ :0:ignore-me :3:a &&
489
+ test_cmp expect actual
490
)
491
'
492
@@ -483,10 +505,11 @@ test_expect_success 'merge of D & E2 fails but has appropriate contents' '
505
git ls-files -o >out &&
506
test_line_count = 2 out &&
507
486
- test $(git rev-parse :2:a) = $(git rev-parse B:a) &&
487
- test $(git rev-parse :3:a/file) = $(git rev-parse E2:a/file) &&
488
- test $(git rev-parse :1:a/file) = $(git rev-parse C:a/file) &&
489
- test $(git rev-parse :0:ignore-me) = $(git rev-parse A:ignore-me) &&
508
+ git rev-parse >expect \
509
+ B:a E2:a/file c:a/file A:ignore-me &&
510
+ git rev-parse >actual \
511
+ :2:a :3:a/file :1:a/file :0:ignore-me &&
512
+ test_cmp expect actual
513
514
test_path_is_file a~HEAD
515
)
@@ -507,10 +530,11 @@ test_expect_success 'merge of E2 & D fails but has appropriate contents' '
530
git ls-files -o >out &&
531
test_line_count = 2 out &&
532
510
- test $(git rev-parse :3:a) = $(git rev-parse B:a) &&
511
- test $(git rev-parse :2:a/file) = $(git rev-parse E2:a/file) &&
512
- test $(git rev-parse :1:a/file) = $(git rev-parse C:a/file) &&
513
- test $(git rev-parse :0:ignore-me) = $(git rev-parse A:ignore-me) &&
533
+ git rev-parse >expect \
534
+ B:a E2:a/file c:a/file A:ignore-me &&
535
+ git rev-parse >actual \
536
+ :3:a :2:a/file :1:a/file :0:ignore-me &&
537
+ test_cmp expect actual
538
539
test_path_is_file a~D^0
540
)
@@ -688,9 +712,15 @@ test_expect_failure 'detect rename/rename/add-source for virtual merge-base' '
712
git ls-files -o >out &&
713
test_line_count = 1 out &&
714
691
- test $(git rev-parse HEAD:b) = $(git rev-parse A:a) &&
692
- test $(git rev-parse HEAD:c) = $(git rev-parse A:a) &&
693
- test "$(cat a)" = "$(printf "1\n2\n3\n4\n5\n6\n7\n8\n")"
715
+ printf "1\n2\n3\n4\n5\n6\n7\n8\n" >correct &&
716
+ git rev-parse >expect \
717
+ A:a A:a \
718
+ correct &&
719
+ git rev-parse >actual \
720
+ :0:b :0:c &&
721
+ git hash-object >>actual \
722
+ a &&
723
+ test_cmp expect actual
724
)
725
'
726
@@ -765,8 +795,11 @@ test_expect_success 'virtual merge base handles rename/rename(1to2)/add-dest' '
795
git ls-files -o >out &&
796
test_line_count = 1 out &&
797
768
- test $(git rev-parse HEAD:a) = $(git rev-parse A:a) &&
769
- test $(git rev-parse HEAD:c) = $(git rev-parse E:c)
798
+ git rev-parse >expect \
799
+ A:a E:c &&
800
+ git rev-parse >actual \
801
+ :0:a :0:c &&
802
+ test_cmp expect actual
803
)
804
'
805
t/t6042-merge-rename-corner-cases.sh
+59
-35
@@ -80,8 +80,11 @@ test_expect_failure 'rename/modify/add-source conflict resolvable' '
80
81
git merge -s recursive C^0 &&
82
83
- test $(git rev-parse B:a) = $(git rev-parse b) &&
84
- test $(git rev-parse C:a) = $(git rev-parse a)
83
+ git rev-parse >expect \
84
+ B:a C:a &&
85
+ git rev-parse >actual \
86
+ b c &&
87
+ test_cmp expect actual
88
)
89
'
90
@@ -124,8 +127,11 @@ test_expect_failure 'conflict caused if rename not detected' '
127
test_line_count = 1 out &&
128
129
test_line_count = 6 c &&
127
- test $(git rev-parse HEAD:a) = $(git rev-parse B:a) &&
128
- test $(git rev-parse HEAD:b) = $(git rev-parse A:b)
130
+ git rev-parse >expect \
131
+ B:a A:b &&
132
+ git rev-parse >actual \
133
+ :0:a :0:b &&
134
+ test_cmp expect actual
135
)
136
'
137
@@ -216,8 +222,11 @@ test_expect_failure 'detect rename/add-source and preserve all data' '
222
test_path_is_file a &&
223
test_path_is_file b &&
224
219
- test $(git rev-parse HEAD:b) = $(git rev-parse A:a) &&
220
- test $(git rev-parse HEAD:a) = $(git rev-parse C:a)
225
+ git rev-parse >expect \
226
+ A:a C:a &&
227
+ git rev-parse >actual \
228
+ :0:b :0:a &&
229
+ test_cmp expect actual
230
)
231
'
232
@@ -239,8 +248,11 @@ test_expect_failure 'detect rename/add-source and preserve all data, merge other
248
test_path_is_file a &&
249
test_path_is_file b &&
250
242
- test $(git rev-parse HEAD:b) = $(git rev-parse A:a) &&
243
- test $(git rev-parse HEAD:a) = $(git rev-parse C:a)
251
+ git rev-parse >expect \
252
+ A:a C:a &&
253
+ git rev-parse >actual \
254
+ :0:b :0:a &&
255
+ test_cmp expect actual
256
)
257
'
258
@@ -336,9 +348,11 @@ test_expect_success 'rename/directory conflict + content merge conflict' '
348
left base right &&
349
test_cmp left newfile~HEAD &&
350
339
- test $(git rev-parse :1:newfile) = $(git rev-parse base:file) &&
340
- test $(git rev-parse :2:newfile) = $(git rev-parse left-conflict:newfile) &&
341
- test $(git rev-parse :3:newfile) = $(git rev-parse right:file) &&
351
+ git rev-parse >expect \
352
+ base:file left-conflict:newfile right:file &&
353
+ git rev-parse >actual \
354
+ :1:newfile :2:newfile :3:newfile &&
355
+ test_cmp expect actual
356
357
test_path_is_file newfile/realfile &&
358
test_path_is_file newfile~HEAD
@@ -458,8 +472,11 @@ test_expect_success 'handle rename/rename (2to1) conflict correctly' '
472
test_path_is_file c~HEAD &&
473
test_path_is_file c~C^0 &&
474
461
- test $(git hash-object c~HEAD) = $(git rev-parse C:a) &&
462
- test $(git hash-object c~C^0) = $(git rev-parse B:b)
475
+ git rev-parse >expect \
476
+ C:a B:b &&
477
+ git hash-object >actual \
478
+ c~HEAD c~C^0 &&
479
+ test_cmp expect actual
480
)
481
'
482
@@ -505,13 +522,15 @@ test_expect_success 'merge has correct working tree contents' '
522
git ls-files -o >out &&
523
test_line_count = 1 out &&
524
508
- test $(git rev-parse :1:a) = $(git rev-parse A:a) &&
509
- test $(git rev-parse :3:b) = $(git rev-parse A:a) &&
510
- test $(git rev-parse :2:c) = $(git rev-parse A:a) &&
511
-
525
test_path_is_missing a &&
513
- test $(git hash-object b) = $(git rev-parse A:a) &&
514
- test $(git hash-object c) = $(git rev-parse A:a)
526
+ git rev-parse >expect \
527
+ A:a A:a A:a \
528
+ A:a A:a &&
529
+ git rev-parse >actual \
530
+ :1:a :3:b :2:c &&
531
+ git hash-object >>actual \
532
+ b c &&
533
+ test_cmp expect actual
534
)
535
'
536
@@ -557,10 +576,11 @@ test_expect_failure 'detect conflict with rename/rename(1to2)/add-source merge'
576
git ls-files -o >out &&
577
test_line_count = 1 out &&
578
560
- test $(git rev-parse 3:a) = $(git rev-parse C:a) &&
561
- test $(git rev-parse 1:a) = $(git rev-parse A:a) &&
562
- test $(git rev-parse 2:b) = $(git rev-parse B:b) &&
563
- test $(git rev-parse 3:c) = $(git rev-parse C:c) &&
579
+ git rev-parse >expect \
580
+ C:a A:a B:b C:C &&
581
+ git rev-parse >actual \
582
+ :3:a :1:a :2:b :3:c &&
583
+ test_cmp expect actual
584
585
test_path_is_file a &&
586
test_path_is_file b &&
@@ -605,8 +625,11 @@ test_expect_failure 'rename/rename/add-source still tracks new a file' '
625
git ls-files -o >out &&
626
test_line_count = 1 out &&
627
608
- test $(git rev-parse HEAD:a) = $(git rev-parse C:a) &&
609
- test $(git rev-parse HEAD:b) = $(git rev-parse A:a)
628
+ git rev-parse >expect \
629
+ C:a A:a &&
630
+ git rev-parse >actual \
631
+ :0:a :0:b &&
632
+ test_cmp expect actual
633
)
634
'
635
@@ -653,16 +676,17 @@ test_expect_success 'rename/rename/add-dest merge still knows about conflicting
676
git ls-files -o >out &&
677
test_line_count = 5 out &&
678
656
- test $(git rev-parse :1:a) = $(git rev-parse A:a) &&
657
- test $(git rev-parse :2:b) = $(git rev-parse C:b) &&
658
- test $(git rev-parse :3:b) = $(git rev-parse B:b) &&
659
- test $(git rev-parse :2:c) = $(git rev-parse C:c) &&
660
- test $(git rev-parse :3:c) = $(git rev-parse B:c) &&
661
-
662
- test $(git hash-object c~HEAD) = $(git rev-parse C:c) &&
663
- test $(git hash-object c~B\^0) = $(git rev-parse B:c) &&
664
- test $(git hash-object b~HEAD) = $(git rev-parse C:b) &&
665
- test $(git hash-object b~B\^0) = $(git rev-parse B:b) &&
679
+ git rev-parse >expect \
680
+ A:a C:b B:b C:c B:c &&
681
+ git rev-parse >actual \
682
+ :1:a :2:b :3:b :2:c :3:c &&
683
+ test_cmp expect actual
684
+
685
+ git rev-parse >expect \
686
+ C:c B:c C:b B:b &&
687
+ git hash-object >actual \
688
+ c~HEAD c~B\^0 b~HEAD b~B\^0 &&
689
+ test_cmp expect actual
690
691
test_path_is_missing b &&
692
test_path_is_missing c