Skip to content

Commit f058386

Browse files
mkiedrowiczgitster
authored andcommitted
tests: make test-apply-criss-cross-rename more robust
I realized that this test does check if git-apply succeeds, but doesn't tell if it applies patches correctly. So I added test_cmp to check it. I also added a test which checks swapping three files. Signed-off-by: Junio C Hamano <[email protected]>
1 parent e8141fc commit f058386

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

t/t4130-apply-criss-cross-rename.sh

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,17 @@ create_file() {
1515
test_expect_success 'setup' '
1616
create_file file1 "File1 contents" &&
1717
create_file file2 "File2 contents" &&
18-
git add file1 file2 &&
18+
create_file file3 "File3 contents" &&
19+
git add file1 file2 file3 &&
1920
git commit -m 1
2021
'
2122

2223
test_expect_success 'criss-cross rename' '
2324
mv file1 tmp &&
2425
mv file2 file1 &&
25-
mv tmp file2
26+
mv tmp file2 &&
27+
cp file1 file1-swapped &&
28+
cp file2 file2-swapped
2629
'
2730

2831
test_expect_success 'diff -M -B' '
@@ -32,7 +35,32 @@ test_expect_success 'diff -M -B' '
3235
'
3336

3437
test_expect_success 'apply' '
35-
git apply diff
38+
git apply diff &&
39+
test_cmp file1 file1-swapped &&
40+
test_cmp file2 file2-swapped
41+
'
42+
43+
test_expect_success 'criss-cross rename' '
44+
git reset --hard &&
45+
mv file1 tmp &&
46+
mv file2 file1 &&
47+
mv file3 file2
48+
mv tmp file3 &&
49+
cp file1 file1-swapped &&
50+
cp file2 file2-swapped &&
51+
cp file3 file3-swapped
52+
'
53+
54+
test_expect_success 'diff -M -B' '
55+
git diff -M -B > diff &&
56+
git reset --hard
57+
'
58+
59+
test_expect_success 'apply' '
60+
git apply diff &&
61+
test_cmp file1 file1-swapped &&
62+
test_cmp file2 file2-swapped &&
63+
test_cmp file3 file3-swapped
3664
'
3765

3866
test_done

0 commit comments

Comments
 (0)