@matheusbsbs / matheus-bagliano / commits / b821ca788b
Fork 0

t6020, t6022, t6035: update merge tests to use test helper functions

Make use of test_path_is_file, test_write_lines, and similar helpers in these old test files. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Elijah Newren committed Feb 27, 2020 at 00:14 UTC b821ca788bee258fb2364722dafe0b60a3219863
3 files changed +47 -47
t/t6020-merge-df.sh
+6 -6
@@ -83,9 +83,9 @@ test_expect_success 'modify/delete + directory/file conflict' '
83 test 4 -eq $(git ls-files -u | wc -l) &&
84 test 1 -eq $(git ls-files -o | wc -l) &&
85
86 - test -f letters/file &&
87 - test -f letters.txt &&
88 - test -f letters~modify
86 + test_path_is_file letters/file &&
87 + test_path_is_file letters.txt &&
88 + test_path_is_file letters~modify
89 '
90
91 test_expect_success 'modify/delete + directory/file conflict; other way' '
@@ -99,9 +99,9 @@ test_expect_success 'modify/delete + directory/file conflict; other way' '
99 test 4 -eq $(git ls-files -u | wc -l) &&
100 test 1 -eq $(git ls-files -o | wc -l) &&
101
102 - test -f letters/file &&
103 - test -f letters.txt &&
104 - test -f letters~HEAD
102 + test_path_is_file letters/file &&
103 + test_path_is_file letters.txt &&
104 + test_path_is_file letters~HEAD
105 '
106
107 test_done
t/t6022-merge-rename.sh
+27 -27
@@ -295,8 +295,8 @@ test_expect_success 'Rename+D/F conflict; renamed file merges + dir not in way'
295 git merge --strategy=recursive dir-not-in-way &&
296
297 git diff --quiet &&
298 - test -f dir &&
299 - printf "1\n2\n3\n4\n5555\n6\n7\n8\n9\n10\n11\n" >expected &&
298 + test_path_is_file dir &&
299 + test_write_lines 1 2 3 4 5555 6 7 8 9 10 11 >expected &&
300 test_cmp expected dir
301 '
302
@@ -316,8 +316,8 @@ test_expect_success 'Rename+D/F conflict; renamed file merges but dir in way' '
316 test_must_fail git diff --quiet &&
317 test_must_fail git diff --cached --quiet &&
318
319 - test -f dir/file-in-the-way &&
320 - test -f dir~HEAD &&
319 + test_path_is_file dir/file-in-the-way &&
320 + test_path_is_file dir~HEAD &&
321 test_cmp expected dir~HEAD
322 '
323
@@ -338,8 +338,8 @@ test_expect_success 'Same as previous, but merged other way' '
338 test_must_fail git diff --quiet &&
339 test_must_fail git diff --cached --quiet &&
340
341 - test -f dir/file-in-the-way &&
342 - test -f dir~renamed-file-has-no-conflicts &&
341 + test_path_is_file dir/file-in-the-way &&
342 + test_path_is_file dir~renamed-file-has-no-conflicts &&
343 test_cmp expected dir~renamed-file-has-no-conflicts
344 '
345
@@ -355,7 +355,7 @@ test_expect_success 'Rename+D/F conflict; renamed file cannot merge, dir not in
355 test_must_fail git diff --quiet &&
356 test_must_fail git diff --cached --quiet &&
357
358 - test -f dir &&
358 + test_path_is_file dir &&
359 cat >expected <<-\EOF &&
360 1
361 2
@@ -391,8 +391,8 @@ test_expect_success 'Rename+D/F conflict; renamed file cannot merge and dir in t
391 test_must_fail git diff --quiet &&
392 test_must_fail git diff --cached --quiet &&
393
394 - test -f dir/file-in-the-way &&
395 - test -f dir~HEAD &&
394 + test_path_is_file dir/file-in-the-way &&
395 + test_path_is_file dir~HEAD &&
396 test_cmp expected dir~HEAD
397 '
398
@@ -409,8 +409,8 @@ test_expect_success 'Same as previous, but merged other way' '
409 test_must_fail git diff --quiet &&
410 test_must_fail git diff --cached --quiet &&
411
412 - test -f dir/file-in-the-way &&
413 - test -f dir~renamed-file-has-conflicts &&
412 + test_path_is_file dir/file-in-the-way &&
413 + test_path_is_file dir~renamed-file-has-conflicts &&
414 cat >expected <<-\EOF &&
415 1
416 2
@@ -463,9 +463,9 @@ test_expect_success 'both rename source and destination involved in D/F conflict
463
464 test_must_fail git diff --quiet &&
465
466 - test -f destdir/foo &&
467 - test -f one &&
468 - test -f destdir~HEAD &&
466 + test_path_is_file destdir/foo &&
467 + test_path_is_file one &&
468 + test_path_is_file destdir~HEAD &&
469 test "stuff" = "$(cat destdir~HEAD)"
470 '
471
@@ -506,9 +506,9 @@ test_expect_success 'pair rename to parent of other (D/F conflicts) w/ untracked
506
507 test 4 -eq $(find . | grep -v .git | wc -l) &&
508
509 - test -d one &&
510 - test -f one~rename-two &&
511 - test -f two &&
509 + test_path_is_dir one &&
510 + test_path_is_file one~rename-two &&
511 + test_path_is_file two &&
512 test "other" = $(cat one~rename-two) &&
513 test "stuff" = $(cat two)
514 '
@@ -526,8 +526,8 @@ test_expect_success 'pair rename to parent of other (D/F conflicts) w/ clean sta
526
527 test 3 -eq $(find . | grep -v .git | wc -l) &&
528
529 - test -f one &&
530 - test -f two &&
529 + test_path_is_file one &&
530 + test_path_is_file two &&
531 test "other" = $(cat one) &&
532 test "stuff" = $(cat two)
533 '
@@ -567,11 +567,11 @@ test_expect_success 'check handling of differently renamed file with D/F conflic
567 test 1 -eq "$(git ls-files -u original | wc -l)" &&
568 test 2 -eq "$(git ls-files -o | wc -l)" &&
569
570 - test -f one/file &&
571 - test -f two/file &&
572 - test -f one~HEAD &&
573 - test -f two~second-rename &&
574 - ! test -f original
570 + test_path_is_file one/file &&
571 + test_path_is_file two/file &&
572 + test_path_is_file one~HEAD &&
573 + test_path_is_file two~second-rename &&
574 + test_path_is_missing original
575 '
576
577 test_expect_success 'setup rename one file to two; directories moving out of the way' '
@@ -606,9 +606,9 @@ test_expect_success 'check handling of differently renamed file with D/F conflic
606 test 1 -eq "$(git ls-files -u original | wc -l)" &&
607 test 0 -eq "$(git ls-files -o | wc -l)" &&
608
609 - test -f one &&
610 - test -f two &&
611 - ! test -f original
609 + test_path_is_file one &&
610 + test_path_is_file two &&
611 + test_path_is_missing original
612 '
613
614 test_expect_success 'setup avoid unnecessary update, normal rename' '
t/t6035-merge-dir-to-symlink.sh
+14 -14
@@ -31,19 +31,19 @@ test_expect_success 'a/b-2/c/d is kept when clobbering symlink b' '
31 git rm --cached a/b &&
32 git commit -m "untracked symlink remains" &&
33 git checkout -f start^0 &&
34 - test -f a/b-2/c/d
34 + test_path_is_file a/b-2/c/d
35 '
36
37 test_expect_success 'checkout should not have deleted a/b-2/c/d' '
38 git checkout HEAD^0 &&
39 git reset --hard master &&
40 git checkout start^0 &&
41 - test -f a/b-2/c/d
41 + test_path_is_file a/b-2/c/d
42 '
43
44 test_expect_success 'setup for merge test' '
45 git reset --hard &&
46 - test -f a/b-2/c/d &&
46 + test_path_is_file a/b-2/c/d &&
47 echo x > a/x &&
48 git add a/x &&
49 git commit -m x &&
@@ -54,7 +54,7 @@ test_expect_success 'Handle D/F conflict, do not lose a/b-2/c/d in merge (resolv
54 git reset --hard &&
55 git checkout baseline^0 &&
56 git merge -s resolve master &&
57 - test -f a/b-2/c/d
57 + test_path_is_file a/b-2/c/d
58 '
59
60 test_expect_success SYMLINKS 'a/b was resolved as symlink' '
@@ -65,7 +65,7 @@ test_expect_success 'Handle D/F conflict, do not lose a/b-2/c/d in merge (recurs
65 git reset --hard &&
66 git checkout baseline^0 &&
67 git merge -s recursive master &&
68 - test -f a/b-2/c/d
68 + test_path_is_file a/b-2/c/d
69 '
70
71 test_expect_success SYMLINKS 'a/b was resolved as symlink' '
@@ -76,7 +76,7 @@ test_expect_success 'Handle F/D conflict, do not lose a/b-2/c/d in merge (resolv
76 git reset --hard &&
77 git checkout master^0 &&
78 git merge -s resolve baseline^0 &&
79 - test -f a/b-2/c/d
79 + test_path_is_file a/b-2/c/d
80 '
81
82 test_expect_success SYMLINKS 'a/b was resolved as symlink' '
@@ -87,7 +87,7 @@ test_expect_success 'Handle F/D conflict, do not lose a/b-2/c/d in merge (recurs
87 git reset --hard &&
88 git checkout master^0 &&
89 git merge -s recursive baseline^0 &&
90 - test -f a/b-2/c/d
90 + test_path_is_file a/b-2/c/d
91 '
92
93 test_expect_success SYMLINKS 'a/b was resolved as symlink' '
@@ -99,8 +99,8 @@ test_expect_failure 'do not lose untracked in merge (resolve)' '
99 git checkout baseline^0 &&
100 >a/b/c/e &&
101 test_must_fail git merge -s resolve master &&
102 - test -f a/b/c/e &&
103 - test -f a/b-2/c/d
102 + test_path_is_file a/b/c/e &&
103 + test_path_is_file a/b-2/c/d
104 '
105
106 test_expect_success 'do not lose untracked in merge (recursive)' '
@@ -108,8 +108,8 @@ test_expect_success 'do not lose untracked in merge (recursive)' '
108 git checkout baseline^0 &&
109 >a/b/c/e &&
110 test_must_fail git merge -s recursive master &&
111 - test -f a/b/c/e &&
112 - test -f a/b-2/c/d
111 + test_path_is_file a/b/c/e &&
112 + test_path_is_file a/b-2/c/d
113 '
114
115 test_expect_success 'do not lose modifications in merge (resolve)' '
@@ -140,7 +140,7 @@ test_expect_success 'merge should not have D/F conflicts (resolve)' '
140 git reset --hard &&
141 git checkout baseline^0 &&
142 git merge -s resolve test2 &&
143 - test -f a/b/c/d
143 + test_path_is_file a/b/c/d
144 '
145
146 test_expect_success SYMLINKS 'a/b-2 was resolved as symlink' '
@@ -151,7 +151,7 @@ test_expect_success 'merge should not have D/F conflicts (recursive)' '
151 git reset --hard &&
152 git checkout baseline^0 &&
153 git merge -s recursive test2 &&
154 - test -f a/b/c/d
154 + test_path_is_file a/b/c/d
155 '
156
157 test_expect_success SYMLINKS 'a/b-2 was resolved as symlink' '
@@ -162,7 +162,7 @@ test_expect_success 'merge should not have F/D conflicts (recursive)' '
162 git reset --hard &&
163 git checkout -b foo test2 &&
164 git merge -s recursive baseline^0 &&
165 - test -f a/b/c/d
165 + test_path_is_file a/b/c/d
166 '
167
168 test_expect_success SYMLINKS 'a/b-2 was resolved as symlink' '