-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathrun-test
More file actions
executable file
·142 lines (123 loc) · 2.44 KB
/
run-test
File metadata and controls
executable file
·142 lines (123 loc) · 2.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/bin/sh
# Test grepdiff -s/--status option
# According to the documentation, -s should show:
# + for file additions
# - for file removals
# ! for file modifications
. ${top_srcdir-.}/tests/common.sh
cat << EOF > diff
--- /dev/null
+++ newfile
@@ -0,0 +1 @@
+content
--- oldfile
+++ /dev/null
@@ -1 +0,0 @@
-content
--- modified
+++ modified
@@ -1 +1 @@
-old
+new
--- another-modified
+++ another-modified
@@ -1,2 +1,2 @@
context
-old content
+new content
EOF
# Test additions and deletions (files with 'content' pattern)
${GREPDIFF} -s 'content' diff 2>errors >output || exit 1
[ -s errors ] && exit 1
cat << EOF | cmp - output || exit 1
+ newfile
- oldfile
! another-modified
EOF
# Test modification only (file with 'new' pattern)
${GREPDIFF} -s 'new' diff 2>errors >output2 || exit 1
[ -s errors ] && exit 1
cat << EOF | cmp - output2 || exit 1
! modified
! another-modified
EOF
# Test with --empty-files-as-absent for file addition
# File with only additions should be treated as new file
cat << EOF > diff3
--- emptyfile
+++ emptyfile
@@ -0,0 +1 @@
+content
@@ -60 +60 @@
-old
+new
EOF
${GREPDIFF} -s --empty-files-as-absent 'content' diff3 2>errors >output3 || exit 1
[ -s errors ] && exit 1
cat << EOF | cmp - output3 || exit 1
+ emptyfile
EOF
# Test with --empty-files-as-absent for file deletion
# File with only deletions should be treated as deleted
cat << EOF > diff4
--- deletedfile
+++ deletedfile
@@ -1 +0,0 @@
-content
@@ -60 +60 @@
-old
+new
EOF
${GREPDIFF} -s --empty-files-as-absent 'content' diff4 2>errors >output4 || exit 1
[ -s errors ] && exit 1
cat << EOF | cmp - output4 || exit 1
- deletedfile
EOF
# Test with context diff format
cat << EOF > diff5
*** /dev/null
--- newfile-ctx
***************
*** 0 ****
--- 1 ----
+ content
*** oldfile-ctx
--- /dev/null
***************
*** 1 ****
- content
--- 0 ----
*** modified-ctx
--- modified-ctx
***************
*** 1 ****
! old content
--- 1 ----
! new content
EOF
${GREPDIFF} -s 'content' diff5 2>errors >output5 || exit 1
[ -s errors ] && exit 1
cat << EOF | cmp - output5 || exit 1
+ newfile-ctx
- oldfile-ctx
! modified-ctx
EOF
# Test context diff with --empty-files-as-absent
cat << EOF > diff6
*** emptyfile-ctx
--- emptyfile-ctx
***************
*** 0 ****
--- 1 ----
+ content
***************
*** 60 ****
! old
--- 60 ----
! new
EOF
${GREPDIFF} -s --empty-files-as-absent 'content' diff6 2>errors >output6 || exit 1
[ -s errors ] && exit 1
cat << EOF | cmp - output6 || exit 1
+ emptyfile-ctx
EOF