Skip to content

Commit cf372dc

Browse files
committed
Merge branch 'en/test-cleanup'
Test cleanup. * en/test-cleanup: t6020: new test with interleaved lexicographic ordering of directories t6022, t6046: test expected behavior instead of testing a proxy for it t3035: prefer test_must_fail to bash negation for git commands t6020, t6022, t6035: update merge tests to use test helper functions t602[1236], t6034: modernize test formatting
2 parents d1075ad + 65bf820 commit cf372dc

9 files changed

+752
-677
lines changed

t/t3035-merge-sparse.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ test_expect_success 'setup' '
2828
git config core.sparseCheckout true &&
2929
echo "/checked-out" >.git/info/sparse-checkout &&
3030
git reset --hard &&
31-
! git merge theirs
31+
test_must_fail git merge theirs
3232
'
3333

3434
test_expect_success 'reset --hard works after the conflict' '
@@ -42,7 +42,7 @@ test_expect_success 'is reset properly' '
4242
'
4343

4444
test_expect_success 'setup: conflict back' '
45-
! git merge theirs
45+
test_must_fail git merge theirs
4646
'
4747

4848
test_expect_success 'Merge abort works after the conflict' '

t/t6020-merge-df.sh

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ test_expect_success 'modify/delete + directory/file conflict' '
8383
test 4 -eq $(git ls-files -u | wc -l) &&
8484
test 1 -eq $(git ls-files -o | wc -l) &&
8585
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
8989
'
9090

9191
test_expect_success 'modify/delete + directory/file conflict; other way' '
@@ -99,9 +99,52 @@ test_expect_success 'modify/delete + directory/file conflict; other way' '
9999
test 4 -eq $(git ls-files -u | wc -l) &&
100100
test 1 -eq $(git ls-files -o | wc -l) &&
101101
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_expect_success 'Simple merge in repo with interesting pathnames' '
108+
# Simple lexicographic ordering of files and directories would be:
109+
# foo
110+
# foo/bar
111+
# foo/bar-2
112+
# foo/bar/baz
113+
# foo/bar-2/baz
114+
# The fact that foo/bar-2 appears between foo/bar and foo/bar/baz
115+
# can trip up some codepaths, and is the point of this test.
116+
test_create_repo name-ordering &&
117+
(
118+
cd name-ordering &&
119+
120+
mkdir -p foo/bar &&
121+
mkdir -p foo/bar-2 &&
122+
>foo/bar/baz &&
123+
>foo/bar-2/baz &&
124+
git add . &&
125+
git commit -m initial &&
126+
127+
git branch main &&
128+
git branch other &&
129+
130+
git checkout other &&
131+
echo other >foo/bar-2/baz &&
132+
git add -u &&
133+
git commit -m other &&
134+
135+
git checkout main &&
136+
echo main >foo/bar/baz &&
137+
git add -u &&
138+
git commit -m main &&
139+
140+
git merge other &&
141+
git ls-files -s >out &&
142+
test_line_count = 2 out &&
143+
git rev-parse :0:foo/bar/baz :0:foo/bar-2/baz >actual &&
144+
git rev-parse HEAD~1:foo/bar/baz other:foo/bar-2/baz >expect &&
145+
test_cmp expect actual
146+
)
147+
105148
'
106149

107150
test_done

t/t6021-merge-criss-cross.sh

Lines changed: 53 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -10,87 +10,58 @@
1010
test_description='Test criss-cross merge'
1111
. ./test-lib.sh
1212

13-
test_expect_success 'prepare repository' \
14-
'echo "1
15-
2
16-
3
17-
4
18-
5
19-
6
20-
7
21-
8
22-
9" > file &&
23-
git add file &&
24-
git commit -m "Initial commit" file &&
25-
git branch A &&
26-
git branch B &&
27-
git checkout A &&
28-
echo "1
29-
2
30-
3
31-
4
32-
5
33-
6
34-
7
35-
8 changed in B8, branch A
36-
9" > file &&
37-
git commit -m "B8" file &&
38-
git checkout B &&
39-
echo "1
40-
2
41-
3 changed in C3, branch B
42-
4
43-
5
44-
6
45-
7
46-
8
47-
9
48-
" > file &&
49-
git commit -m "C3" file &&
50-
git branch C3 &&
51-
git merge -m "pre E3 merge" A &&
52-
echo "1
53-
2
54-
3 changed in E3, branch B. New file size
55-
4
56-
5
57-
6
58-
7
59-
8 changed in B8, branch A
60-
9
61-
" > file &&
62-
git commit -m "E3" file &&
63-
git checkout A &&
64-
git merge -m "pre D8 merge" C3 &&
65-
echo "1
66-
2
67-
3 changed in C3, branch B
68-
4
69-
5
70-
6
71-
7
72-
8 changed in D8, branch A. New file size 2
73-
9" > file &&
74-
git commit -m D8 file'
75-
76-
test_expect_success 'Criss-cross merge' 'git merge -m "final merge" B'
77-
78-
cat > file-expect <<EOF
79-
1
80-
2
81-
3 changed in E3, branch B. New file size
82-
4
83-
5
84-
6
85-
7
86-
8 changed in D8, branch A. New file size 2
87-
9
88-
EOF
89-
90-
test_expect_success 'Criss-cross merge result' 'cmp file file-expect'
91-
92-
test_expect_success 'Criss-cross merge fails (-s resolve)' \
93-
'git reset --hard A^ &&
94-
test_must_fail git merge -s resolve -m "final merge" B'
13+
test_expect_success 'prepare repository' '
14+
test_write_lines 1 2 3 4 5 6 7 8 9 >file &&
15+
git add file &&
16+
git commit -m "Initial commit" file &&
17+
18+
git branch A &&
19+
git branch B &&
20+
git checkout A &&
21+
22+
test_write_lines 1 2 3 4 5 6 7 "8 changed in B8, branch A" 9 >file &&
23+
git commit -m "B8" file &&
24+
git checkout B &&
25+
26+
test_write_lines 1 2 "3 changed in C3, branch B" 4 5 6 7 8 9 >file &&
27+
git commit -m "C3" file &&
28+
git branch C3 &&
29+
30+
git merge -m "pre E3 merge" A &&
31+
32+
test_write_lines 1 2 "3 changed in E3, branch B. New file size" 4 5 6 7 "8 changed in B8, branch A" 9 >file &&
33+
git commit -m "E3" file &&
34+
35+
git checkout A &&
36+
git merge -m "pre D8 merge" C3 &&
37+
test_write_lines 1 2 "3 changed in C3, branch B" 4 5 6 7 "8 changed in D8, branch A. New file size 2" 9 >file &&
38+
39+
git commit -m D8 file
40+
'
41+
42+
test_expect_success 'Criss-cross merge' '
43+
git merge -m "final merge" B
44+
'
45+
46+
test_expect_success 'Criss-cross merge result' '
47+
cat <<-\EOF >file-expect &&
48+
1
49+
2
50+
3 changed in E3, branch B. New file size
51+
4
52+
5
53+
6
54+
7
55+
8 changed in D8, branch A. New file size 2
56+
9
57+
EOF
58+
59+
test_cmp file-expect file
60+
'
61+
62+
test_expect_success 'Criss-cross merge fails (-s resolve)' '
63+
git reset --hard A^ &&
64+
test_must_fail git merge -s resolve -m "final merge" B
65+
'
9566

9667
test_done

0 commit comments

Comments
 (0)