Skip to content

Commit 9f697de

Browse files
newrengitster
authored andcommitted
t6022, t6046: test expected behavior instead of testing a proxy for it
In t6022, we were testing for file being overwritten (or not) based on an output message instead of checking for the file being overwritten. Since we can check for the file being overwritten via mtime updates, check that instead. In t6046, we were largely checking for both the expected behavior and a proxy for it, which is unnecessary. The calls to test-tool also were a bit cryptic. Make them a little clearer. Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d5bb92e commit 9f697de

File tree

2 files changed

+70
-34
lines changed

2 files changed

+70
-34
lines changed

t/t6022-merge-rename.sh

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,23 @@ test_expect_success 'merge of identical changes in a renamed file' '
242242
rm -f A M N &&
243243
git reset --hard &&
244244
git checkout change+rename &&
245+
246+
test-tool chmtime =31337 B &&
247+
test-tool chmtime --get B >old-mtime &&
245248
GIT_MERGE_VERBOSITY=3 git merge change >out &&
246-
test_i18ngrep "^Skipped B" out &&
249+
250+
test-tool chmtime --get B >new-mtime &&
251+
test_cmp old-mtime new-mtime &&
252+
247253
git reset --hard HEAD^ &&
248254
git checkout change &&
255+
256+
test-tool chmtime =-1 M &&
257+
test-tool chmtime --get M >old-mtime &&
249258
GIT_MERGE_VERBOSITY=3 git merge change+rename >out &&
250-
test_i18ngrep ! "^Skipped B" out
259+
260+
test-tool chmtime --get B >new-mtime &&
261+
test $(cat old-mtime) -lt $(cat new-mtime)
251262
'
252263

253264
test_expect_success 'setup for rename + d/f conflicts' '

t/t6046-merge-skip-unneeded-updates.sh

Lines changed: 57 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,16 @@ test_expect_success '1a-L: Modify(A)/Modify(B), change on B subset of A' '
7171
7272
git checkout A^0 &&
7373
74-
test-tool chmtime =31337 b &&
75-
test-tool chmtime -v +0 b >expected-mtime &&
74+
test-tool chmtime =-1 b &&
75+
test-tool chmtime --get b >old-mtime &&
7676
7777
GIT_MERGE_VERBOSITY=3 git merge -s recursive B^0 >out 2>err &&
7878
79-
test_i18ngrep "Skipped b" out &&
8079
test_must_be_empty err &&
8180
82-
test-tool chmtime -v +0 b >actual-mtime &&
83-
test_cmp expected-mtime actual-mtime &&
81+
# Make sure b was NOT updated
82+
test-tool chmtime --get b >new-mtime &&
83+
test_cmp old-mtime new-mtime &&
8484
8585
git ls-files -s >index_files &&
8686
test_line_count = 1 index_files &&
@@ -102,9 +102,14 @@ test_expect_success '1a-R: Modify(A)/Modify(B), change on B subset of A' '
102102
103103
git checkout B^0 &&
104104
105+
test-tool chmtime =-1 b &&
106+
test-tool chmtime --get b >old-mtime &&
105107
GIT_MERGE_VERBOSITY=3 git merge -s recursive A^0 >out 2>err &&
106108
107-
test_i18ngrep "Auto-merging b" out &&
109+
# Make sure b WAS updated
110+
test-tool chmtime --get b >new-mtime &&
111+
test $(cat old-mtime) -lt $(cat new-mtime) &&
112+
108113
test_must_be_empty err &&
109114
110115
git ls-files -s >index_files &&
@@ -165,10 +170,10 @@ test_expect_success '2a-L: Modify/rename, merge into modify side' '
165170
166171
git checkout A^0 &&
167172
173+
test_path_is_missing c &&
168174
GIT_MERGE_VERBOSITY=3 git merge -s recursive B^0 >out 2>err &&
169175
170-
test_i18ngrep ! "Skipped c" out &&
171-
test_must_be_empty err &&
176+
test_path_is_file c &&
172177
173178
git ls-files -s >index_files &&
174179
test_line_count = 1 index_files &&
@@ -193,9 +198,14 @@ test_expect_success '2a-R: Modify/rename, merge into rename side' '
193198
194199
git checkout B^0 &&
195200
201+
test-tool chmtime =-1 c &&
202+
test-tool chmtime --get c >old-mtime &&
196203
GIT_MERGE_VERBOSITY=3 git merge -s recursive A^0 >out 2>err &&
197204
198-
test_i18ngrep ! "Skipped c" out &&
205+
# Make sure c WAS updated
206+
test-tool chmtime --get c >new-mtime &&
207+
test $(cat old-mtime) -lt $(cat new-mtime) &&
208+
199209
test_must_be_empty err &&
200210
201211
git ls-files -s >index_files &&
@@ -256,16 +266,15 @@ test_expect_success '2b-L: Rename+Mod(A)/Mod(B), B mods subset of A' '
256266
257267
git checkout A^0 &&
258268
259-
test-tool chmtime =31337 c &&
260-
test-tool chmtime -v +0 c >expected-mtime &&
261-
269+
test-tool chmtime =-1 c &&
270+
test-tool chmtime --get c >old-mtime &&
262271
GIT_MERGE_VERBOSITY=3 git merge -s recursive B^0 >out 2>err &&
263272
264-
test_i18ngrep "Skipped c" out &&
265273
test_must_be_empty err &&
266274
267-
test-tool chmtime -v +0 c >actual-mtime &&
268-
test_cmp expected-mtime actual-mtime &&
275+
# Make sure c WAS updated
276+
test-tool chmtime --get c >new-mtime &&
277+
test_cmp old-mtime new-mtime &&
269278
270279
git ls-files -s >index_files &&
271280
test_line_count = 1 index_files &&
@@ -290,9 +299,12 @@ test_expect_success '2b-R: Rename+Mod(A)/Mod(B), B mods subset of A' '
290299
291300
git checkout B^0 &&
292301
302+
test_path_is_missing c &&
293303
GIT_MERGE_VERBOSITY=3 git merge -s recursive A^0 >out 2>err &&
294304
295-
test_i18ngrep "Auto-merging c" out &&
305+
# Make sure c now present (and thus was updated)
306+
test_path_is_file c &&
307+
296308
test_must_be_empty err &&
297309
298310
git ls-files -s >index_files &&
@@ -361,13 +373,18 @@ test_expect_success '2c: Modify b & add c VS rename b->c' '
361373
362374
git checkout A^0 &&
363375
376+
test-tool chmtime =-1 c &&
377+
test-tool chmtime --get c >old-mtime &&
364378
GIT_MERGE_VERBOSITY=3 &&
365379
export GIT_MERGE_VERBOSITY &&
366380
test_must_fail git merge -s recursive B^0 >out 2>err &&
367381
368382
test_i18ngrep "CONFLICT (rename/add): Rename b->c" out &&
369-
test_i18ngrep ! "Skipped c" out &&
370-
test_must_be_empty err
383+
test_must_be_empty err &&
384+
385+
# Make sure c WAS updated
386+
test-tool chmtime --get c >new-mtime &&
387+
test $(cat old-mtime) -lt $(cat new-mtime)
371388
372389
# FIXME: rename/add conflicts are horribly broken right now;
373390
# when I get back to my patch series fixing it and
@@ -460,11 +477,13 @@ test_expect_success '3a-L: bq_1->foo/bq_2 on A, foo/->bar/ on B' '
460477
461478
git checkout A^0 &&
462479
480+
test_path_is_missing bar/bq &&
463481
GIT_MERGE_VERBOSITY=3 git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err &&
464482
465-
test_i18ngrep ! "Skipped bar/bq" out &&
466483
test_must_be_empty err &&
467484
485+
test_path_is_file bar/bq &&
486+
468487
git ls-files -s >index_files &&
469488
test_line_count = 2 index_files &&
470489
@@ -488,11 +507,13 @@ test_expect_success '3a-R: bq_1->foo/bq_2 on A, foo/->bar/ on B' '
488507
489508
git checkout B^0 &&
490509
510+
test_path_is_missing bar/bq &&
491511
GIT_MERGE_VERBOSITY=3 git -c merge.directoryRenames=true merge -s recursive A^0 >out 2>err &&
492512
493-
test_i18ngrep ! "Skipped bar/bq" out &&
494513
test_must_be_empty err &&
495514
515+
test_path_is_file bar/bq &&
516+
496517
git ls-files -s >index_files &&
497518
test_line_count = 2 index_files &&
498519
@@ -552,11 +573,13 @@ test_expect_success '3b-L: bq_1->foo/bq_2 on A, foo/->bar/ on B' '
552573
553574
git checkout A^0 &&
554575
576+
test_path_is_missing bar/bq &&
555577
GIT_MERGE_VERBOSITY=3 git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err &&
556578
557-
test_i18ngrep ! "Skipped bar/bq" out &&
558579
test_must_be_empty err &&
559580
581+
test_path_is_file bar/bq &&
582+
560583
git ls-files -s >index_files &&
561584
test_line_count = 2 index_files &&
562585
@@ -580,11 +603,13 @@ test_expect_success '3b-R: bq_1->foo/bq_2 on A, foo/->bar/ on B' '
580603
581604
git checkout B^0 &&
582605
606+
test_path_is_missing bar/bq &&
583607
GIT_MERGE_VERBOSITY=3 git -c merge.directoryRenames=true merge -s recursive A^0 >out 2>err &&
584608
585-
test_i18ngrep ! "Skipped bar/bq" out &&
586609
test_must_be_empty err &&
587610
611+
test_path_is_file bar/bq &&
612+
588613
git ls-files -s >index_files &&
589614
test_line_count = 2 index_files &&
590615
@@ -654,16 +679,16 @@ test_expect_failure '4a: Change on A, change on B subset of A, dirty mods presen
654679
git checkout A^0 &&
655680
echo "File rewritten" >b &&
656681
657-
test-tool chmtime =31337 b &&
658-
test-tool chmtime -v +0 b >expected-mtime &&
682+
test-tool chmtime =-1 b &&
683+
test-tool chmtime --get b >old-mtime &&
659684
660685
GIT_MERGE_VERBOSITY=3 git merge -s recursive B^0 >out 2>err &&
661686
662-
test_i18ngrep "Skipped b" out &&
663687
test_must_be_empty err &&
664688
665-
test-tool chmtime -v +0 b >actual-mtime &&
666-
test_cmp expected-mtime actual-mtime &&
689+
# Make sure b was NOT updated
690+
test-tool chmtime --get b >new-mtime &&
691+
test_cmp old-mtime new-mtime &&
667692
668693
git ls-files -s >index_files &&
669694
test_line_count = 1 index_files &&
@@ -722,16 +747,16 @@ test_expect_success '4b: Rename+Mod(A)/Mod(B), change on B subset of A, dirty mo
722747
git checkout A^0 &&
723748
echo "File rewritten" >c &&
724749
725-
test-tool chmtime =31337 c &&
726-
test-tool chmtime -v +0 c >expected-mtime &&
750+
test-tool chmtime =-1 c &&
751+
test-tool chmtime --get c >old-mtime &&
727752
728753
GIT_MERGE_VERBOSITY=3 git merge -s recursive B^0 >out 2>err &&
729754
730-
test_i18ngrep "Skipped c" out &&
731755
test_must_be_empty err &&
732756
733-
test-tool chmtime -v +0 c >actual-mtime &&
734-
test_cmp expected-mtime actual-mtime &&
757+
# Make sure c was NOT updated
758+
test-tool chmtime --get c >new-mtime &&
759+
test_cmp old-mtime new-mtime &&
735760
736761
git ls-files -s >index_files &&
737762
test_line_count = 1 index_files &&

0 commit comments

Comments
 (0)