Skip to content

Commit 6ac767e

Browse files
newrengitster
authored andcommitted
t6036, t6042: prefer test_cmp to sequences of test
Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5b0b971 commit 6ac767e

File tree

2 files changed

+130
-73
lines changed

2 files changed

+130
-73
lines changed

t/t6036-recursive-corner-cases.sh

Lines changed: 71 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,14 @@ test_expect_success 'merge simple rename+criss-cross with no modifications' '
7272
git ls-files -o >out &&
7373
test_line_count = 3 out &&
7474
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
8083
)
8184
'
8285

@@ -145,11 +148,14 @@ test_expect_success 'merge criss-cross + rename merges with basic modification'
145148
git ls-files -o >out &&
146149
test_line_count = 3 out &&
147150
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
153159
)
154160
'
155161

@@ -224,19 +230,23 @@ test_expect_success 'git detects differently handled merges conflict' '
224230
git ls-files -o >out &&
225231
test_line_count = 1 out &&
226232
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
229238
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 &&
232241
>empty &&
233242
test_must_fail git merge-file \
234243
-L "Temporary merge branch 2" \
235244
-L "" \
236245
-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
240250
)
241251
'
242252

@@ -311,8 +321,11 @@ test_expect_success 'git detects conflict merging criss-cross+modify/delete' '
311321
git ls-files -u >out &&
312322
test_line_count = 2 out &&
313323
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
316329
)
317330
'
318331

@@ -330,8 +343,11 @@ test_expect_success 'git detects conflict merging criss-cross+modify/delete, rev
330343
git ls-files -u >out &&
331344
test_line_count = 2 out &&
332345
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
335351
)
336352
'
337353

@@ -443,8 +459,11 @@ test_expect_success 'merge of D & E1 fails but has appropriate contents' '
443459
git ls-files -o >out &&
444460
test_line_count = 1 out &&
445461
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
448467
)
449468
'
450469

@@ -463,8 +482,11 @@ test_expect_success 'merge of E1 & D fails but has appropriate contents' '
463482
git ls-files -o >out &&
464483
test_line_count = 1 out &&
465484
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
468490
)
469491
'
470492

@@ -483,10 +505,11 @@ test_expect_success 'merge of D & E2 fails but has appropriate contents' '
483505
git ls-files -o >out &&
484506
test_line_count = 2 out &&
485507
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
490513
491514
test_path_is_file a~HEAD
492515
)
@@ -507,10 +530,11 @@ test_expect_success 'merge of E2 & D fails but has appropriate contents' '
507530
git ls-files -o >out &&
508531
test_line_count = 2 out &&
509532
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
514538
515539
test_path_is_file a~D^0
516540
)
@@ -688,9 +712,15 @@ test_expect_failure 'detect rename/rename/add-source for virtual merge-base' '
688712
git ls-files -o >out &&
689713
test_line_count = 1 out &&
690714
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
694724
)
695725
'
696726

@@ -765,8 +795,11 @@ test_expect_success 'virtual merge base handles rename/rename(1to2)/add-dest' '
765795
git ls-files -o >out &&
766796
test_line_count = 1 out &&
767797
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
770803
)
771804
'
772805

t/t6042-merge-rename-corner-cases.sh

Lines changed: 59 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,11 @@ test_expect_failure 'rename/modify/add-source conflict resolvable' '
8080
8181
git merge -s recursive C^0 &&
8282
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
8588
)
8689
'
8790

@@ -124,8 +127,11 @@ test_expect_failure 'conflict caused if rename not detected' '
124127
test_line_count = 1 out &&
125128
126129
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
129135
)
130136
'
131137

@@ -216,8 +222,11 @@ test_expect_failure 'detect rename/add-source and preserve all data' '
216222
test_path_is_file a &&
217223
test_path_is_file b &&
218224
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
221230
)
222231
'
223232

@@ -239,8 +248,11 @@ test_expect_failure 'detect rename/add-source and preserve all data, merge other
239248
test_path_is_file a &&
240249
test_path_is_file b &&
241250
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
244256
)
245257
'
246258

@@ -336,9 +348,11 @@ test_expect_success 'rename/directory conflict + content merge conflict' '
336348
left base right &&
337349
test_cmp left newfile~HEAD &&
338350
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
342356
343357
test_path_is_file newfile/realfile &&
344358
test_path_is_file newfile~HEAD
@@ -458,8 +472,11 @@ test_expect_success 'handle rename/rename (2to1) conflict correctly' '
458472
test_path_is_file c~HEAD &&
459473
test_path_is_file c~C^0 &&
460474
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
463480
)
464481
'
465482

@@ -505,13 +522,15 @@ test_expect_success 'merge has correct working tree contents' '
505522
git ls-files -o >out &&
506523
test_line_count = 1 out &&
507524
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-
512525
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
515534
)
516535
'
517536

@@ -557,10 +576,11 @@ test_expect_failure 'detect conflict with rename/rename(1to2)/add-source merge'
557576
git ls-files -o >out &&
558577
test_line_count = 1 out &&
559578
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
564584
565585
test_path_is_file a &&
566586
test_path_is_file b &&
@@ -605,8 +625,11 @@ test_expect_failure 'rename/rename/add-source still tracks new a file' '
605625
git ls-files -o >out &&
606626
test_line_count = 1 out &&
607627
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
610633
)
611634
'
612635

@@ -653,16 +676,17 @@ test_expect_success 'rename/rename/add-dest merge still knows about conflicting
653676
git ls-files -o >out &&
654677
test_line_count = 5 out &&
655678
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
666690
667691
test_path_is_missing b &&
668692
test_path_is_missing c

0 commit comments

Comments
 (0)