-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathrun-test
More file actions
executable file
·126 lines (105 loc) · 3.44 KB
/
run-test
File metadata and controls
executable file
·126 lines (105 loc) · 3.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/bin/sh
# Test coverage for binary patch content handling
# Tests binary patch formats: "GIT binary patch" and "literal"
. ${top_srcdir-.}/tests/common.sh
# Test 1: GIT binary patch format
cat << 'EOF' > git-binary-patch.patch
diff --git a/file1.bin b/file1.bin
new file mode 100644
index 0000000..abc123
Binary files /dev/null and b/file1.bin differ
GIT binary patch
literal 12
TcmZn~00001
diff --git a/file2.txt b/file2.txt
new file mode 100644
index 0000000..def456
--- /dev/null
+++ b/file2.txt
@@ -0,0 +1 @@
+text content
EOF
# Test 2: literal format binary patch
cat << 'EOF' > literal-patch.patch
diff --git a/file3.bin b/file3.bin
new file mode 100644
index 0000000..ghi789
Binary files /dev/null and b/file3.bin differ
literal 8
PcmZn~0001
diff --git a/file4.txt b/file4.txt
new file mode 100644
index 0000000..jkl012
--- /dev/null
+++ b/file4.txt
@@ -0,0 +1 @@
+more text
EOF
# Test 3: delta format binary patch (working format)
cat << 'EOF' > delta-patch.patch
diff --git a/file5.bin b/file5.bin
new file mode 100644
index 0000000..mno345
Binary files /dev/null and b/file5.bin differ
delta 16
XcmZn~00002Tc
diff --git a/file6.txt b/file6.txt
new file mode 100644
index 0000000..pqr678
--- /dev/null
+++ b/file6.txt
@@ -0,0 +1 @@
+final text
EOF
# Test filtering binary files with GIT binary patch format - should include binary content
echo "Testing GIT binary patch format (include)..."
${FILTERDIFF} --git-extended-diffs=include --git-prefixes=strip -i "file1.bin" git-binary-patch.patch 2>errors1 >result1 || exit 1
[ -s errors1 ] && { echo "Unexpected errors in test 1:"; cat errors1; exit 1; }
cat << 'EOF' | cmp - result1 || { echo "Test 1 failed"; exit 1; }
diff --git a/file1.bin b/file1.bin
new file mode 100644
index 0000000..abc123
Binary files /dev/null and b/file1.bin differ
GIT binary patch
literal 12
TcmZn~00001
EOF
# Test filtering binary files with literal format - should include binary content
echo "Testing literal format (include)..."
${FILTERDIFF} --git-extended-diffs=include --git-prefixes=strip -i "file3.bin" literal-patch.patch 2>errors2 >result2 || exit 1
[ -s errors2 ] && { echo "Unexpected errors in test 2:"; cat errors2; exit 1; }
cat << 'EOF' | cmp - result2 || { echo "Test 2 failed"; exit 1; }
diff --git a/file3.bin b/file3.bin
new file mode 100644
index 0000000..ghi789
Binary files /dev/null and b/file3.bin differ
literal 8
PcmZn~0001
EOF
# Test filtering binary files with delta format - should include binary content
echo "Testing delta format (include)..."
${FILTERDIFF} --git-extended-diffs=include --git-prefixes=strip -i "file5.bin" delta-patch.patch 2>errors3 >result3 || exit 1
[ -s errors3 ] && { echo "Unexpected errors in test 3:"; cat errors3; exit 1; }
cat << 'EOF' | cmp - result3 || { echo "Test 3 failed"; exit 1; }
diff --git a/file5.bin b/file5.bin
new file mode 100644
index 0000000..mno345
Binary files /dev/null and b/file5.bin differ
delta 16
XcmZn~00002Tc
EOF
# Test excluding binary files - should skip binary content
echo "Testing binary patch exclusion..."
${FILTERDIFF} --git-extended-diffs=include --git-prefixes=strip -x "file1.bin" git-binary-patch.patch 2>errors4 >result4 || exit 1
[ -s errors4 ] && { echo "Unexpected errors in test 4:"; cat errors4; exit 1; }
cat << 'EOF' | cmp - result4 || { echo "Test 4 failed"; exit 1; }
diff --git a/file2.txt b/file2.txt
new file mode 100644
index 0000000..def456
--- /dev/null
+++ b/file2.txt
@@ -0,0 +1 @@
+text content
EOF
echo "All binary format tests passed!"
exit 0